Closed
Description
see symfony/symfony#27917 + symfony/symfony#12312
https://symfony.com/doc/current/validation/custom_constraint.html
instead of
if (!is_string($value)) {
- throw new UnexpectedTypeException($value, 'string');
+ throw new UnexpectedValueException($value, 'string');
}
This will cause a violation to be raised instead.
The "string"
value is used with This value should be of type {{ type }}.
, thus should be translator friendly. E.g. core uses phpdoc notation to avoid any grammar being used here (string|int
instead of string or integer
and Some&Other
instead of Some and Other
).