in reply to Data::FormValidator question
The answer to my question is yes, one must write a custom constraint. I got this reply from the module author (Mark Stosberg):
Fred, if using the 'dependencies' system doesn't solve your problem, I think you are right. You could write a custom constraint for b or c, such that they only kick-in if A is present.
He also suggested that I propose any new functionality to the maintainers list.
Solving my problem I used the following code (see Data::FormValidator for explaination)
# .. snip # Part of my hash to pass to D::FV constraints => { dn_id => 'OK_int', b => { constraint => 'custom_constraint_sub_name', params => [ qw/ b a / ], }, c => { constraint => 'custom_constraint_sub_name', params => [ qw/ c a / ], }, } # .. snip ... # Defining my constraint routine elsewhere: ################################# sub match_custom_constraint_sub_name { my $val = shift; my $a = shift; if ( $a eq 'N' ) { return match_another_custom_constraint($val) ; } else { return "0"; # use this default value }
-------------------------------------
Nothing is too wonderful to be true
-- Michael Faraday
|
|---|