Skip to content

Commit

Permalink
Merge pull request #4 from RobinHoutevelts/master
Browse files Browse the repository at this point in the history
  • Loading branch information
dannyvankooten authored Nov 19, 2021
2 parents b0568b6 + 5732d3e commit 1b0080a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Validator/Constraints/VatNumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@
*/
class VatNumber extends Constraint
{
public const INVALID_ERROR_CODE = '59421d43-d474-489c-b18c-7701329d51a0';

public $message = '"{{ string }}" does not look like a valid VAT number.';
}
1 change: 1 addition & 0 deletions src/Validator/Constraints/VatNumberValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public function validate($value, Constraint $constraint)
if (false === $valid) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ string }}', $value)
->setCode(VatNumber::INVALID_ERROR_CODE)
->addViolation();
}
}
Expand Down
1 change: 1 addition & 0 deletions tests/Validator/Constraints/VatNumberValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public function testInvalidValues($value)
$this->validator->validate($value, $constraint);
$this->buildViolation('myMessage')
->setParameter('{{ string }}', $value)
->setCode('59421d43-d474-489c-b18c-7701329d51a0')
->assertRaised();
}

Expand Down

0 comments on commit 1b0080a

Please sign in to comment.