feat!: Validation event payload property "name" renamed to "path"
This commit is contained in:
parent
a1476d9986
commit
7c2a9e8110
@ -88,8 +88,7 @@ export default class FormularioField extends Vue {
|
||||
}
|
||||
|
||||
public get model (): unknown {
|
||||
const model = this.hasModel ? 'value' : 'proxy'
|
||||
return this.modelGetConverter(this[model])
|
||||
return this.modelGetConverter(this.hasModel ? this.value : this.proxy)
|
||||
}
|
||||
|
||||
public set model (value: unknown) {
|
||||
@ -185,16 +184,12 @@ export default class FormularioField extends Vue {
|
||||
|
||||
public runValidation (): Promise<Violation[]> {
|
||||
this.validationRun = this.validate().then(violations => {
|
||||
const validationChanged = !shallowEquals(violations, this.violations)
|
||||
this.violations = violations
|
||||
|
||||
if (validationChanged) {
|
||||
this.emitValidation({
|
||||
name: this.fullPath,
|
||||
violations: this.violations,
|
||||
})
|
||||
if (!shallowEquals(this.violations, violations)) {
|
||||
this.emitValidation(this.fullPath, violations)
|
||||
}
|
||||
|
||||
this.violations = violations
|
||||
|
||||
return this.violations
|
||||
})
|
||||
|
||||
@ -213,10 +208,10 @@ export default class FormularioField extends Vue {
|
||||
})
|
||||
}
|
||||
|
||||
private emitValidation (payload: { name: string; violations: Violation[] }): void {
|
||||
this.$emit('validation', payload)
|
||||
private emitValidation (path: string, violations: Violation[]): void {
|
||||
this.$emit('validation', { path, violations })
|
||||
if (typeof this.__FormularioForm_emitValidation === 'function') {
|
||||
this.__FormularioForm_emitValidation(payload)
|
||||
this.__FormularioForm_emitValidation(path, violations)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -136,8 +136,8 @@ export default class FormularioForm extends Vue {
|
||||
}
|
||||
|
||||
@Provide('__FormularioForm_emitValidation')
|
||||
private emitValidation (payload: ValidationEventPayload): void {
|
||||
this.$emit('validation', payload)
|
||||
private emitValidation (path: string, violations: Violation[]): void {
|
||||
this.$emit('validation', { path, violations })
|
||||
}
|
||||
|
||||
@Watch('state', { deep: true })
|
||||
|
@ -129,7 +129,7 @@ describe('FormularioField', () => {
|
||||
await flushPromises()
|
||||
|
||||
expect(wrapper.emitted('validation')).toEqual([[{
|
||||
name: 'field',
|
||||
path: 'field',
|
||||
violations: [{
|
||||
rule: 'required',
|
||||
args: expect.any(Array),
|
||||
|
@ -371,7 +371,7 @@ describe('FormularioForm', () => {
|
||||
|
||||
expect(wrapper.emitted('validation')).toBeTruthy()
|
||||
expect(wrapper.emitted('validation')).toEqual([[{
|
||||
name: 'foo',
|
||||
path: 'foo',
|
||||
violations: [],
|
||||
}]])
|
||||
})
|
||||
@ -386,7 +386,7 @@ describe('FormularioForm', () => {
|
||||
|
||||
expect(wrapper.emitted('validation')).toBeTruthy()
|
||||
expect(wrapper.emitted('validation')).toEqual([[ {
|
||||
name: 'foo',
|
||||
path: 'foo',
|
||||
violations: [ {
|
||||
rule: expect.any(String),
|
||||
args: ['foo'],
|
||||
|
Loading…
Reference in New Issue
Block a user