It doesn't look for the thousands/decimal separators for the locale.
Rightfully the locale should come from the webbrowser but I don't have a
clue how to obtain that kind of information.
Here is a test for the decimal place as "." character only.
*** ./t/filters/nonnumeric.t.orig Thu May 29 05:23:02 2008
--- ./t/filters/nonnumeric.t Mon Sep 1 10:36:50 2008
***************
*** 1,20 ****
use strict;
use warnings;
! use Test::More tests => 2;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->element('Text')->name('foo')->filter('NonNumeric');
my $original_foo = " 0123-4567 (8a9)";
my $filtered_foo = "0123456789";
! $form->process( { foo => $original_foo, } );
# foo is filtered
is( $form->param('foo'), $filtered_foo, 'foo filtered' );
is( $form->params->{foo}, $filtered_foo, 'foo filtered' );
--- 1,26 ----
use strict;
use warnings;
! use Test::More tests => 3;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->element('Text')->name('foo')->filter('NonNumeric');
+ $form->element('Text')->name('bar')->filter('NonNumeric');
my $original_foo = " 0123-4567 (8a9)";
my $filtered_foo = "0123456789";
! my $original_bar = '2.54%';
! my $filtered_bar = '2.54';
!
! $form->process( { foo => $original_foo, bar => $original_bar} );
# foo is filtered
is( $form->param('foo'), $filtered_foo, 'foo filtered' );
is( $form->params->{foo}, $filtered_foo, 'foo filtered' );
+ is( $form->param('bar'), $filtered_bar, 'bar filtered' );
+
On Mon Sep 01 10:27:26 2008, ANDREMAR wrote:
Show quoted text> A test would be cool :) also, how does it work with locales?
>
> Thanks for the bug and interest :)
>
> Andreas
>
> On 1. sep.. 2008, at 16.19, "Rod Taylor via RT" <bug-HTML-
> FormFu@rt.cpan.org
> > wrote:
>
> > Mon Sep 01 10:19:05 2008: Request 38899 was acted upon.
> > Transaction: Ticket created by rtaylor
> > Queue: HTML-FormFu
> > Subject: Filter Non-Numeric strips decimal
> > Broken in: 0.03003
> > Severity: Normal
> > Owner: Nobody
> > Requestors: rod.taylor@gmail.com
> > Status: new
> > Ticket <URL:
http://rt.cpan.org/Ticket/Display.html?id=38899 >
> >
> >
> > The NonNumeric filter strips the decimal so "2.55" becomes "255".
> >
> > I had a field which was populated to include 2 decimal places and
> > submit
> > would shift the value 2 digits left. Quite annoying. I think Least
> > Surprise is to keep decimal places.
> >
> >
> > Below patch causes it to keep the decimal place.
> >
> > *** NonNumeric.pm.orig Mon Sep 1 10:14:18 2008
> > --- NonNumeric.pm Mon Sep 1 10:14:31 2008
> > ***************
> > *** 3,9 ****
> > use strict;
> > use base 'HTML::FormFu::Filter::Regex';
> >
> > ! sub match {qr/\D+/}
> >
> > 1;
> >
> > --- 3,9 ----
> > use strict;
> > use base 'HTML::FormFu::Filter::Regex';
> >
> > ! sub match {qr/[^\d.]/}
> >
> > 1;
> >