From c74d6fa0f301807dd7335689a4c7c5c8de2d4e55 Mon Sep 17 00:00:00 2001 From: Thomas Bisignani Date: Wed, 14 Nov 2018 10:37:21 +0100 Subject: [PATCH] Update custom_constraint.rst --- validation/custom_constraint.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/validation/custom_constraint.rst b/validation/custom_constraint.rst index 4e947290ef0..b946901c6f8 100644 --- a/validation/custom_constraint.rst +++ b/validation/custom_constraint.rst @@ -65,6 +65,10 @@ The validator class is also simple, and only has one required method ``validate( { public function validate($value, Constraint $constraint) { + if (!$constraint instanceof ContainsAlphanumeric) { + throw new UnexpectedTypeException($constraint, ContainsAlphanumeric::class); + } + // custom constraints should ignore null and empty values to allow // other constraints (NotBlank, NotNull, etc.) take care of that if (null === $value || '' === $value) {