FAQ
Hi,

I am relatively new to Catalyst and am having trouble getting the FV_eq_with
constraint method of Data::FormValidator to work.

my $f = $c->form(
required => [qw/email password/],
constraint_methods => {
email => [
email()
],
password => FV_eq_with('confirm_password')
},
filters => ['trim']
);

Data::Dumper output of the form method return value:

[debug] $VAR1 = bless( {
'profile' => {
'dependencies' => {},
'filters' => [
'trim'
],
'defaults_regexp_map' => {},
'constraint_method_regexp_map' => {},
'constraint_methods' => {
'email' => [
sub {
"DU
MMY" }
],
'password' => sub
{ "D
UMMY" }
},
'dependency_groups' => {},
'constraint_regexp_map' => {},
'constraints' => {},
'required' => [
'email',
'password'
],
'require_some' => {},
'field_filter_regexp_map' => {},
'field_filters' => {}
},
'validate_invalid' => [
[
'email',
'email'
],
'password'
],
'__FILTERED_DATA' => {},
'__INPUT_DATA' => {
'email' => 'sa',
'password' => 'a',
'confirm_password' => 'a',
'security_image' => '',
'submit' => 'submit'
},
'missing' => {},
'__CURRENT_CONSTRAINT_FIELD' => 'password',
'__CURRENT_CONSTRAINT_VALUE' => 'a',
'valid' => {},
'__CURRENT_CONSTRAINT_NAME' => 'eq_with',
'__UNTAINT_THIS' => 0,
'unknown' => {
'confirm_password' => 'a',
'submit' => 'submit'
},
'invalid' => {
'email' => [
'email'
],
'password' => [
'eq_with'
]
}
}, 'Data::FormValidator::Results' );

I went into the Data::FormValidators Constraints.pm and found the constraint
routine.



sub FV_eq_with {
my ($other_field) = @_;
return sub {
my $dfv = shift;
$dfv->name_this('eq_with');

my $curr_val = $dfv->get_current_constraint_value;

my $data = $dfv->get_filtered_data;
# Sometimes the data comes through both ways...
my $other_val = (ref $data->{$other_field}) ?
$data->{$other_field}[0] : $data->{$other_field};

return ($curr_val eq $other_val);
}

}


By hacking around in here, i can see that the reference to the
Data::FormValidator $dfv is not being passed.

Does anyone have any pointers to help me get this working.

Many Thanks.
Darren.
--
View this message in context: http://www.nabble.com/FormValidator-and-FV_eq_with-constraint-method-tp20703984p20703984.html
Sent from the Catalyst Web Framework mailing list archive at Nabble.com.

Search Discussions

  • Darrenferguson at Nov 27, 2008 at 9:10 am
    Answering my own question again. It appears that you have to add all fields
    to either the required or optional array in order that Data::FormValidator
    processes them correctly.
    --
    View this message in context: http://www.nabble.com/FormValidator-and-FV_eq_with-constraint-method-tp20703984p20715702.html
    Sent from the Catalyst Web Framework mailing list archive at Nabble.com.
  • Matthias Dietrich at Nov 28, 2008 at 10:42 am
    Hi,
    Answering my own question again. It appears that you have to add all
    fields
    to either the required or optional array in order that
    Data::FormValidator
    processes them correctly.
    can you post a sample?

    Thanks,
    matt


    -------------- next part --------------
    A non-text attachment was scrubbed...
    Name: PGP.sig
    Type: application/pgp-signature
    Size: 194 bytes
    Desc: This is a digitally signed message part
    Url : http://lists.scsys.co.uk/pipermail/catalyst/attachments/20081128/0ee02c52/PGP.pgp
  • Darren Ferguson at Nov 28, 2008 at 11:10 am

    Matthias Dietrich-3 wrote:

    can you post a sample?

    Thanks,
    matt
    Hi,

    In my original example I add confirm_password to the optional list of
    fields.


    my $f = $c->form(
    required => [qw/email password/],
    optional => [qw/confirm_password/],
    constraint_methods => {
    email => [
    email()
    ],
    password => FV_eq_with('confirm_password')
    },
    filters => ['trim']
    );

    --
    View this message in context: http://www.nabble.com/FormValidator-and-FV_eq_with-constraint-method-tp20703984p20732642.html
    Sent from the Catalyst Web Framework mailing list archive at Nabble.com.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcatalyst @
categoriescatalyst, perl
postedNov 26, '08 at 4:12p
activeNov 28, '08 at 11:10a
posts4
users2
websitecatalystframework.org
irc#catalyst

People

Translate

site design / logo © 2021 Grokbase