Subject: | Empty optional values that would normally be skipped are run through the validation routines if there are multiple values |
It's not uncommon to have multiple fields with the same name, but not require that they all (or any of them) be filled in. If this is the case D::FV will run the constraints on the missing (undef) values when they would normally be skipped. And since constraint routines can't return undef+but+true it will fail.
For example, this (an optional field w 2 defined valid values) doesn't fail:
perl -MData::FormValidator -le 'print Data::FormValidator->check({foo => [1,2]}, {optional => q(foo), constraint_methods => { foo => qr/^\d$/ }})->invalid;'
Neither does this (an optional field w 2 undef values):
perl -MData::FormValidator -le 'print Data::FormValidator->check({foo => [undef, undef]}, {optional => q(foo), constraint_methods => { foo => qr/^\d$/ }})->invalid;'
But if you mix them, it fails on the undef (missing) value:
perl -MData::FormValidator -le 'print Data::FormValidator->check({foo => [1,undef]}, {optional => q(foo), constraint_methods => { foo => qr/^\d$/ }})->invalid;'
It should treat the 2nd value as just missing and not run it through the validation routine since the field itself is optional.