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.