[dfv] Multiple constraint_methods for a field
Status: Inactive
Brought to you by:
markjugg
|
From: David W. <dav...@va...> - 2016-07-11 00:24:41
|
I have a form field "email". I want to apply two constraints to it.
Firstly, I want to check that the email entered looks valid. Secondly,
if (and only if) the email entered looks valid I want to check that is
known to be associated with a society. That second check is specific to
the particular functionality of my web site.
Here is my entry for the email field in constraint_methods.
email => [
{
constraint_method => email ,
name => 'email_valid'
} ,
{
constraint_method => representative_known ,
fields => [ qw / society / ]
} ,
] ,
I've used the email constraint from Data::FormValidator::Constraints and
provided my own name to associate to my own error message. I have
another error message associated with the representative_known constraint.
When I test with an invalid email address I get both error messages
returned in an array, which suggests to me that both constraints have
been executed. How do I stop the representative_known constraint from
being run if the email fails the email constraint?
Dave
|