Before & After: Should not throw an exception if the value is empty.
Hey, I have a validator rule like this:
$validator->make($_POST, 'dateOfBirth'=>'date:Y/m/d|before:today' );
As you can see, the date field is not required, it is optional, but if someone wants to enter it, it must be in the given format and before today. The problem is when the user leaves the field empty, we get an error that says:
... Argument #1 ($date) must be of type string, null given, called in ...
So you get the point. I am pretty sure we should leave checking the value for empty/null values for the "required" rule and return true if the field is empty, in "before and after" rules.
I think the logic is correct. You doesn't require the field but you don't say it is optional. Use "nullable" if it is not required. Then the validation bails is the field is empty.