diff --git a/src/validation/ErrorObserver.ts b/src/validation/ErrorObserver.ts index 250536f..847a5e6 100644 --- a/src/validation/ErrorObserver.ts +++ b/src/validation/ErrorObserver.ts @@ -45,10 +45,13 @@ export class ErrorObserverRegistry { observer.callback(errors) } else if ( observer.field && - !Array.isArray(errors) && - has(errors, observer.field) + !Array.isArray(errors) ) { - observer.callback(errors[observer.field]) + if (has(errors, observer.field)) { + observer.callback(errors[observer.field]) + } else { + observer.callback([]) + } } }) } diff --git a/test/unit/FormularioForm.test.js b/test/unit/FormularioForm.test.js index 85106ac..9bd6d97 100644 --- a/test/unit/FormularioForm.test.js +++ b/test/unit/FormularioForm.test.js @@ -423,4 +423,32 @@ describe('FormularioForm', () => { expect(Object.keys(wrapper.vm.$refs.form.mergedFieldErrors).length).toBe(0) }) + + it('Local errors resetted when errors prop cleared', async () => { + const wrapper = mount({ + data: () => ({ values: {}, errors: { input: ['failure'] } }), + template: ` + + + {{ error.message }} + + + ` + }) + + await flushPromises() + expect(wrapper.find('span').exists()).toBe(true) + + wrapper.vm.errors = {} + await flushPromises() + expect(wrapper.find('span').exists()).toBe(false) + }) })