Closed
Description
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?