refactor: replace economic code fields with individual and legal variants, add equal length validation

This commit is contained in:
2026-06-03 17:48:54 +03:30
parent 8d6fa8860b
commit 694b2ec946
23 changed files with 272 additions and 101 deletions
@@ -68,6 +68,13 @@ export class FormErrorsService {
const info = errors['invalidUsername'];
out.push({ key: 'invalidUsername', message: info.message ?? `${label} معتبر نیست.` });
}
if (errors['equalLength']) {
const info = errors['equalLength'];
out.push({
key: 'equalLength',
message: `تعداد کاراکترهای ${label} باید برابر با ${info.length} باشد.`,
});
}
if (errors['invalidFiscalId']) {
const info = errors['invalidFiscalId'];
@@ -0,0 +1,19 @@
import { AbstractControl, ValidationErrors, ValidatorFn } from '@angular/forms';
export function equalLengthValidator(length: number): ValidatorFn {
return (control: AbstractControl): ValidationErrors | null => {
const v = control.value;
if (v === null || v === undefined || v === '') {
return null;
}
const normalized = String(v);
return normalized.length !== length
? {
equalLength: {
length,
},
}
: null;
};
}
+1
View File
@@ -1,3 +1,4 @@
export * from './equalLength.validator';
export * from './fiscal-id.validator';
export * from './greater.validator';
export * from './iban.validator';