1
0
mirror of synced 2024-11-22 13:26:06 +03:00

fix: Removed validation on field value change, when errorBehavior is not live

This commit is contained in:
1on 2020-10-20 18:26:41 +03:00
parent 9aedaa1b0e
commit 06c79905a8
2 changed files with 32 additions and 1 deletions

View File

@ -276,7 +276,11 @@ export default class FormularioInput extends Vue {
@Watch('proxy') @Watch('proxy')
onProxyChanged (newValue, oldValue): void { onProxyChanged (newValue, oldValue): void {
if (this.errorBehavior === ERROR_BEHAVIOR.LIVE) {
this.performValidation() this.performValidation()
} else {
this.validationErrors = []
}
if (!this.isVmodeled && !shallowEqualObjects(newValue, oldValue)) { if (!this.isVmodeled && !shallowEqualObjects(newValue, oldValue)) {
this.context.model = newValue this.context.model = newValue
} }

View File

@ -58,6 +58,33 @@ describe('FormularioInput', () => {
expect(wrapper.find('span').exists()).toBe(false) expect(wrapper.find('span').exists()).toBe(false)
}) })
it('no validation on value change when errorBehavior is not live', async () => {
const wrapper = mount(FormularioInput, {
propsData: {
name: 'test',
validation: 'required|in:abcdef',
validationMessages: {in: 'the value was different than expected'},
errorBehavior: 'submit',
value: 'other value'
},
scopedSlots: {
default: `<div>
<input type="text" v-model="props.context.model">
<span v-for="error in props.context.allErrors">{{ error.message }}</span>
</div>`
}
})
await flushPromises()
expect(wrapper.find('span').exists()).toBe(false)
const input = wrapper.find('input[type="text"]')
input.element.value = 'test'
input.trigger('input')
await flushPromises()
expect(wrapper.find('input[type="text"]').element.value).toBe('test')
expect(wrapper.find('span').exists()).toBe(false)
})
it('allows custom field-rule level validation functions', async () => { it('allows custom field-rule level validation functions', async () => {
const wrapper = mount(FormularioInput, { const wrapper = mount(FormularioInput, {
propsData: { propsData: {