You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But when the date field is within an array, it automatically makes it required.
This is invalid:
$validator = newValitron\Validator([
[ "dateCreated" => null ]
]);
$validator->rule("optional", "*.dateCreated"); // This line doesn't affect Valitron's behaviour$validator->rule("dateFormat", "*.dateCreated", "Y-m-d\TH:i:sP");
Expected behaviour
Valitron should check the dateFormat rule in the same way whether or not it's in an array, which means, to treat the dateCreated field as optional.
Notes
This also happens, for example with numeric, integer, lengthMin and other rules.
The text was updated successfully, but these errors were encountered:
I think (and testing seems to confirm it) this is already fixed in the dev-master branch. Can you please try it with composer require vlucas/valitron:dev-master
If it's fixed there I'll make a new release. If it's not, I'll try and fix it first :)
Use case
Validate an optional field within a numeric array of associative arrays.
Example
Normally, the
dateFormat
rule allowsnull
value (which is correct, because it's not required).This is valid:
But when the date field is within an array, it automatically makes it required.
This is invalid:
Expected behaviour
Valitron should check the
dateFormat
rule in the same way whether or not it's in an array, which means, to treat thedateCreated
field as optional.Notes
This also happens, for example with
numeric
,integer
,lengthMin
and other rules.The text was updated successfully, but these errors were encountered: