feat(consultant_scoring): added validation for last first and middle name for scoring

This commit is contained in:
misha
2026-08-14 12:16:03 +03:00
parent 52a01bee12
commit 85482173ad
5 changed files with 95 additions and 6 deletions

View File

@@ -49,7 +49,26 @@ void main() {
);
expect(parsed.fieldErrors['last_name'], 'Укажите фамилию');
expect(parsed.fieldErrors['agreement_accepted'], 'Примите условия оферты');
expect(
parsed.fieldErrors['agreement_accepted'],
'Примите условия оферты',
);
});
test('maps name format errors', () {
final parsed = parseLaravelValidationErrors(
dio422({
'errors': {
'last_name': ['The last name format is invalid.'],
'first_name': ['The first name format is invalid.'],
'middle_name': ['The middle name format is invalid.'],
},
}),
);
expect(parsed.fieldErrors['last_name'], 'Некорректная фамилия');
expect(parsed.fieldErrors['first_name'], 'Некорректное имя');
expect(parsed.fieldErrors['middle_name'], 'Некорректное отчество');
});
test('falls back to generic message for non-422 DioException', () {

View File

@@ -25,6 +25,34 @@ void main() {
expect(PassportDataValidator.validate(valid), isEmpty);
});
test('rejects names that do not match Alfa Bank pattern', () {
final errors = PassportDataValidator.validate(
valid.copyWith(
lastName: 'Regress14LastName',
firstName: 'Regress14Name',
middleName: 'Regress14middleName',
),
);
expect(errors['last_name'], 'Некорректная фамилия');
expect(errors['first_name'], 'Некорректное имя');
expect(errors['middle_name'], 'Некорректное отчество');
});
test('allows hyphenated names and empty middle name', () {
final errors = PassportDataValidator.validate(
valid.copyWith(
lastName: 'Салтыков-Щедрин',
firstName: 'Mary Jane',
middleName: '',
),
);
expect(errors.containsKey('last_name'), isFalse);
expect(errors.containsKey('first_name'), isFalse);
expect(errors.containsKey('middle_name'), isFalse);
});
test('requires empty text fields', () {
final errors = PassportDataValidator.validate(
valid.copyWith(lastName: '', firstName: null),