Description
The TypeValidator seems to be useless whenever the value being validated is NULL. It completely ignores the type I've configured it to enforce.
After debugging this for quite some time, it turns out the issue lies in the following line(s) of code:
if (null === $value) {
return;
}
What is the reasoning behind this short-circuit logic?
If I configure my TypeValidator to enforce a value to be of type integer (or string, or whatever), then I expect it to throw a validation error whenever the value is not of the desired type... especially when it's NULL.
Allowing NULL to always be valid regardless of what type you've asked it to enforce seems to be counter-intuitive and leads to some unusual/unexpected validation behavior.
Coincidentally, I went through the history of this file and noticed that these very lines of code were once removed (2 years ago):
Why have they been reintroduced? Was this a merging oversight?