Skip to content

[Validatior] Constraint value type check inconsistency #6799

Closed
@rybakit

Description

@rybakit

I've run into a problem while validating date value:

$errors = $validator->validateValue($date, new Constraints\Date());

If $date is not a string (or object with __toString() method), code above will throw UnexpectedTypeException.
it's not what I expected to see, but I can understand the reasons laying behind this behaviour.

But after further investigation, I've found out that Constraints\Range (and maybe others) in the same situation just adds violation ("This value should be a valid number") without throwing the exception. So what is the correct behaviour for such cases? Should they both throw UnexpectedTypeException or add violation?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions