Skip to content

[Validator] New UnexpectedValueException #10551

Closed
@ro0NL

Description

@ro0NL

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions