Skip to content

Commit 324d85f

Browse files
committed
minor symfony#10671 Update custom_constraint.rst (thomasbisignani)
This PR was submitted for the 4.1 branch but it was merged into the 2.8 branch instead (closes symfony#10671). Discussion ---------- Update custom_constraint.rst Just added the constraint check to limit the `ContainsAlphanumericValidator` use with the `ContainsAlphanumeric` constraint. Commits ------- bb30126 Update custom_constraint.rst
2 parents 6e38d74 + bb30126 commit 324d85f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

validation/custom_constraint.rst

+4
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ The validator class is also simple, and only has one required method ``validate(
6565
{
6666
public function validate($value, Constraint $constraint)
6767
{
68+
if (!$constraint instanceof ContainsAlphanumeric) {
69+
throw new UnexpectedTypeException($constraint, ContainsAlphanumeric::class);
70+
}
71+
6872
// custom constraints should ignore null and empty values to allow
6973
// other constraints (NotBlank, NotNull, etc.) take care of that
7074
if (null === $value || '' === $value) {

0 commit comments

Comments
 (0)