Subject: | Data::FormValidator::Results->get_filtered_data drops invalid values |
Date: | Fri, 1 Aug 2008 11:24:34 -0400 |
To: | bug-Data-FormValidator [...] rt.cpan.org |
From: | Lisa Hagemann <lhagemann [...] dyndns.com> |
reported for Data::FormValidator v4.61
observed similar behavior in v4.5
The Documentation reads:
Data::FormValidator::filters -- "This is a reference to an array of
filters that will be applied to ALL optional and required fields,
before any constraints are applied."
Data::FormValidator::Constraints->get_filtered_data -- "Returns the
filtered data as a hashref, ..."
I would expect then, that the get_filtered_data would return ALL
fields. But in fact it only returns the filtered data for those filed
that are valid.
This may be FAD, and if so, the documentation should be updated to
reflect such.
A simple script below demonstrates the behavior:
-------
#!/usr/bin/perl
use warnings;
use strict;
use Data::FormValidator;
use Data::Dumper;
$Data::Dumper::Indent = 1;
my $input = {
'f_name' => ' 2spaces_each ',
'l_name' => 'foobar',
};
my $profile = {
'optional' => ['l_name'],
'required' => ['f_name'],
'filters' => ['trim'],
};
my $dfv_results = Data::FormValidator->check($input, $profile);
print Dumper($dfv_results->get_filtered_data, $dfv_results->invalid());
$profile->{'constraint_methods'} = {
'f_name' => qr/^\D$/,
};
$dfv_results = Data::FormValidator->check($input, $profile);
print Dumper($dfv_results->get_filtered_data, $dfv_results->invalid());
------
Lisa L. Hagemann
Application Developer
Dynamic Network Services, Inc.
http://www.dyndns.com | http://www.dynect.com