Subject: | HTML::FormFu::Constraint::_process_when considers 'not' only for specific 'values' -- not for the field value's sole existence |
Date: | Fri, 13 Aug 2010 19:23:19 +0200 |
To: | bug-HTML-FormFu [...] rt.cpan.org |
From: | Gernot Kieseritzky <gernotk [...] gmail.com> |
HTML::FormFu::Constraint supports the 'when' option allowing to turn on
the constraint depending on the
1) presence of ANY value for the field name spec. under 'field' key
or
2) presence of a list of specific values for the field name spec. under
'field'
It also supports a negation using 'not' for case 2). Unfortunately, it
does not support negation of 1) because of the code line
return 0 if !defined $when_field_value;
Which should be replace with
my $ok;
$ok = defined $when_field_value;
$ok = $when->{not} ? !$ok : $ok;
return 0 if $ok;