Skip to content

Commit

Permalink
fix eVehiclePassportNumber rules
Browse files Browse the repository at this point in the history
  • Loading branch information
ssortia committed Jul 19, 2024
1 parent 8f5cc38 commit a5e2ec2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ilb/ajvinstance",
"version": "3.2.0",
"version": "3.2.1",
"description": "",
"type": "module",
"scripts": {
Expand Down
7 changes: 7 additions & 0 deletions src/__tests__/rules/eVehiclePassportNumber.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ describe('Тесты валидатора номера ПТС', () => {
expect(isValid).toBe(true);
});

it('Должен вернуть false, если номер ПТС длиннее 15 символов', () => {
const validVin = '1234567897894561111';
const isValid = eVehiclePassportNumber.condition(validVin);

expect(isValid).toBe(false);
});

it('Должен вернуть false, если номер ЭПТС содержит буквы', () => {
const vinWithCyrillic = '77TM181468'; // номер ПТС содержит символы латиницы
const isValid = eVehiclePassportNumber.condition(vinWithCyrillic);
Expand Down
2 changes: 1 addition & 1 deletion src/keywords/rules/eVehiclePassportNumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export default {
return "Номер ЭПТС должен быть длиной 15 символов и содержать только цифры";
},
condition: (value) => {
const regex = /\d{15}/;
const regex = /^\d{15}$/;

return regex.test(value);
},
Expand Down

0 comments on commit a5e2ec2

Please sign in to comment.