1
0
mirror of synced 2024-11-25 14:56:03 +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')
onProxyChanged (newValue, oldValue): void {
this.performValidation()
if (this.errorBehavior === ERROR_BEHAVIOR.LIVE) {
this.performValidation()
} else {
this.validationErrors = []
}
if (!this.isVmodeled && !shallowEqualObjects(newValue, oldValue)) {
this.context.model = newValue
}

View File

@ -58,6 +58,33 @@ describe('FormularioInput', () => {
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 () => {
const wrapper = mount(FormularioInput, {
propsData: {