diff --git a/packages/synapse-bridge/src/patterns/NirField/NirField.vue b/packages/synapse-bridge/src/patterns/NirField/NirField.vue index fbf8849389..30e7440b83 100644 --- a/packages/synapse-bridge/src/patterns/NirField/NirField.vue +++ b/packages/synapse-bridge/src/patterns/NirField/NirField.vue @@ -101,8 +101,6 @@ export default defineComponent({ numberErrors: [] as string[], keyErrors: [] as string[], - - isSingleField: false, } }, watch: { @@ -126,14 +124,16 @@ export default defineComponent({ this.keyValue = newValue.slice(NUMBER_LENGTH, DOUBLE_FIELD) this.validateNumberValue(this.numberValue) - this.validateKeyValue(this.keyValue) + if (!this.isSingleField) { + this.validateKeyValue(this.keyValue) + } }, }, }, - created(): void { - this.isSingleField = this.nirLength === SINGLE_FIELD - }, computed: { + isSingleField(): boolean { + return this.nirLength === SINGLE_FIELD + }, textFieldOptions() { return deepMerge(config, this.$attrs) }, @@ -159,6 +159,9 @@ export default defineComponent({ * Generate the validation rules for the key field */ keyRules(): ValidationRule[] { + if (this.isSingleField) { + return [] + } let rules = [ exactLength(KEY_LENGTH, true, { default: locales.errorLengthKey, diff --git a/packages/synapse-bridge/src/patterns/NirField/tests/NirField.spec.ts b/packages/synapse-bridge/src/patterns/NirField/tests/NirField.spec.ts index 6a63068520..119441c1ec 100644 --- a/packages/synapse-bridge/src/patterns/NirField/tests/NirField.spec.ts +++ b/packages/synapse-bridge/src/patterns/NirField/tests/NirField.spec.ts @@ -574,4 +574,22 @@ describe('NirField', () => { expect(wrapper.text()).toContain(locales.errorRequiredNumber) expect(wrapper.text()).toContain(locales.errorRequiredKey) }) + + it('do not validate the key field in single field mode', async () => { + const wrapper = mount(NirField, { + global: { + plugins: [vuetify], + }, + propsData: { + modelValue: '1234567890123', + nirLength: 13, + required: true, + }, + }) + + await wrapper.setProps({ modelValue: '' }) + + expect(wrapper.text()).toContain(locales.errorRequiredNumber) + expect(wrapper.text()).not.toContain(locales.errorRequiredKey) + }); })