Re: [dfv] require_some must have values
Status: Inactive
Brought to you by:
markjugg
|
From: Mark S. <ma...@su...> - 2012-04-25 13:02:18
|
On 04/24/2012 12:16 PM, Louis-David Mitterrand wrote:
> Hi,
>
> I'm a bit stuck here.
>
> Among this 'require_some' entry, I need at least one of them to return a
> 1 value. These are individual checkboxes that return either 0
> (defaults_regexp_map) or 1 (when checked).
>
> require_some => {
> notify=>[1, qw/notify_down notify_up notify_new notify_gone notify_back/],
> },
>
> defaults_regexp_map => {
> qr/^notify_/ => 0,
> },
>
> How can I specify a constraint that would kick in when all the 'notify'
> values are 0?
Constraints must always be tied to a single field. So, you would
arbitrary pick one of the fields to apply the constraint to, like
notify_down.
You would then write a custom constraint for it, and the constraint
would only return success if all the notify values were zero. Here's the
section on writing custom constraints:
https://metacpan.org/module/Data::FormValidator::Constraints#WRITING-YOUR-OWN-CONSTRAINT-ROUTINES
Mark
|