Skip to content

Commit 40c5191

Browse files
committed
Fix: only digits are allowed in PWZ.
1 parent b3ae0ea commit 40c5191

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/Constraints/PwzCheckDigitValidator.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ public function validate($value, Constraint $constraint): void
2424
throw new UnexpectedValueException($value, 'string');
2525
}
2626

27+
if (preg_match('#[^0-9]#', $value)) {
28+
$this->context->buildViolation($constraint->message)
29+
->setParameter('{{ string }}', $value)
30+
->setCode('INVALID_CHECK_DIGIT')
31+
->addViolation();
32+
33+
return;
34+
}
35+
2736
$original = $value;
2837
$check_digit = (int) $value[0];
2938
$value = substr($value, 1); // remove check digit

0 commit comments

Comments
 (0)