Skip Menu |

This queue is for tickets about the Data-FormValidator CPAN distribution.

Maintainer(s)' notes

This is the bug queue for Data::FormValidator.

Report information
The Basics
Id: 19592
Status: resolved
Priority: 0/
Queue: Data-FormValidator

People
Owner: Nobody in particular
Requestors: banb [...] yahoo.co.jp
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in: 4.14
Fixed in: (no value)



Subject: unconsistency in 'filters'
The description 'Filters modify the data, so use them carefully.' in 'filters' section of perldoc is not accurate. In most cases, 'filters' do not modify the data itself. We can get modified data through DFV::Results::valid('field') method only on the valid condition. The exception is on values in array reference of hash input. my %h = ( key => [ ' value1 ', ' value2 ' ] ); Data::FormValidator->check( \%h, { required => [ 'key' ], filters => [ 'trim' ], }); This code make %h's values trimmed as { key => [ 'value1', 'value2' ] }. I think that modification on input data is very very useful, but bit risky for some people. I wish I can get filtered data even for invalid fields through Results object.
CC: "Data::FormValidator list" <cascade-dataform [...] lists.sourceforge.net>
Subject: Re: [rt.cpan.org #19592] unconsistency in 'filters'
Date: Tue, 30 May 2006 09:37:04 -0400
To: Guest via RT <bug-Data-FormValidator [...] rt.cpan.org>
From: Mark Stosberg <mark [...] summersault.com>
On Mon, May 29, 2006 at 10:14:28PM -0400, Guest via RT wrote: Show quoted text
> Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=19592 > > > > The description > 'Filters modify the data, so use them carefully.' > in 'filters' section of perldoc > is not accurate. > > In most cases, 'filters' do not modify the data itself. > We can get modified data through DFV::Results::valid('field') method > only on the valid condition. > > The exception is on values in array reference of hash input. > > my %h = ( key => [ ' value1 ', ' value2 ' ] ); > Data::FormValidator->check( > \%h, > { required => [ 'key' ], > filters => [ 'trim' ], > }); > > This code make %h's values trimmed as { key => [ 'value1', 'value2' ] }. > > > I think that modification on input data is very very useful, but bit > risky for some people. I wish I can get filtered data even for invalid > fields through Results object.
Thanks for the report. I agree that the documentation should clearer that it is a copy of data that is modified. Also, it's a bug that your input was ever modified. Mark
CC: "Data::FormValidator list" <cascade-dataform [...] lists.sourceforge.net>
Subject: Re: [rt.cpan.org #19592] inconsistency in 'filters' (fixed)
Date: Tue, 30 May 2006 22:30:26 -0400
To: Guest via RT <bug-Data-FormValidator [...] rt.cpan.org>
From: Mark Stosberg <mark [...] summersault.com>
On Mon, May 29, 2006 at 10:14:28PM -0400, Guest via RT wrote: Show quoted text
> > In most cases, 'filters' do not modify the data itself. > We can get modified data through DFV::Results::valid('field') method > only on the valid condition. > > The exception is on values in array reference of hash input. > > my %h = ( key => [ ' value1 ', ' value2 ' ] ); > Data::FormValidator->check( > \%h, > { required => [ 'key' ], > filters => [ 'trim' ], > }); > > This code make %h's values trimmed as { key => [ 'value1', 'value2' ] }.
This has been fixed in my tree by not modifying the input in this case. It will appear in the next release. Mark Show quoted text
> > > I think that modification on input data is very very useful, but bit > risky for some people. I wish I can get filtered data even for invalid > fields through Results object. >
-- . . . . . . . . . . . . . . . . . . . . . . . . . . . Mark Stosberg Principal Developer mark@summersault.com Summersault, LLC 765-939-9301 ext 202 database driven websites . . . . . http://www.summersault.com/ . . . . . . . .