I can't see anything obvious that is wrong. Can you give us some
examples of inputs where this doesn't work? What do you put in, and
what do you get out?
Here are some samples that work fine for me (although the filter seems
to be a little bit lax in it's translation in the last example):
use Data::FormValidator;
my $profile = {
required => [qw( test )],
field_filters => { test => ['decimal'] },
};
my @tests = (
'123.45',
'$123.45',
'$ 123.45 ',
' $ 1,234.56',
'123 $ 23.45',
'sdfjsdfjsdf 0.0001 kdfasdf',
);
foreach my $test (@tests) {
my $results = Data::FormValidator->check({ test => $test }, $profile);
print "$test => ", $results->valid->{'test'}, "\n";
}
=========================
Output:
123.45 => 123.45
$123.45 => 123.45
$ 123.45 => 123.45
$ 1,234.56 => 1.234.56
123 $ 23.45 => 12323.45
sdfjsdfjsdf 0.0001 kdfasdf => 0.0001
Cheers,
Cees
On Apr 7, 2005 3:11 PM, Jeff MacDonald <suppressed> wrote:
> HI,
>
> I'm trying to use field_filters, to pull $'s out of fields for dollar
> amounts, as people inevitablly put that in..
>
> It ain't doing it... here is my code..
>
> if ($self->param('isLoggedIn')) {
> ($results,$err_page) = $self->check_rm('poolcheck::bookPool', {
> required => [qw/fullname address primary_phone workdate am_pm/],
> optional => [qw/secondary_phone email pooltype coveroff accessby
> public_comments workdate pending completed confirmed com
> bination prebooked blank1 blank1 invoicenum quoted/],
> constraints => {zipcode => 'zip',
> primary_phone => 'american_phone',
> secondary_phone => 'american_phone',
> email => 'email',
>
> workdate => sub { # check to make sure workdate
> doesn't precede today
> my $val = shift;
> my ($y,$m,$d) = split(/-/,$val);
> my $pastdate = 0;
> $pastdate = 1 if
> (Delta_Days($y,$m,$d,Today()) <= 0);
> return $pastdate; },
> },
> filters => ['trim'],
> field_filters => { quoted => ['decimal'], },
> msgs => {any_errors => 'err__',
> prefix=>'err_'},
> });
> }
>
> Any idea's or things i could try ?
>
> Thanks.
> --
> Jeff MacDonald
> http://www.halifaxbudolife.ca
>
> ---------------------------------------------------------------------
> Web Archive: http://www.mail-archive.com/suppressed/
> http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
> To unsubscribe, e-mail: suppressed
> For additional commands, e-mail: suppressed
>
>
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/suppressed/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.