r3081 - in /packages/libdata-formvalidator-perl/trunk: ./ debian/
lib/Data/ lib/Data/FormValidator/ t/
gregoa-guest at users.alioth.debian.org
gregoa-guest at users.alioth.debian.org
Sat Jun 17 15:23:05 UTC 2006
Author: gregoa-guest
Date: Sat Jun 17 15:23:04 2006
New Revision: 3081
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=3081
Log:
* New upstream release.
* Set Standards-Version to 3.7.2.
* Set Debhelper Compatibility Level to 5.
Added:
packages/libdata-formvalidator-perl/trunk/t/filters_shouldnt_modify.t
- copied unchanged from r3080, packages/libdata-formvalidator-perl/branches/upstream/current/t/filters_shouldnt_modify.t
Modified:
packages/libdata-formvalidator-perl/trunk/Changes
packages/libdata-formvalidator-perl/trunk/MANIFEST
packages/libdata-formvalidator-perl/trunk/META.yml
packages/libdata-formvalidator-perl/trunk/README
packages/libdata-formvalidator-perl/trunk/debian/changelog
packages/libdata-formvalidator-perl/trunk/debian/compat
packages/libdata-formvalidator-perl/trunk/debian/control
packages/libdata-formvalidator-perl/trunk/lib/Data/FormValidator.pm
packages/libdata-formvalidator-perl/trunk/lib/Data/FormValidator/Filters.pm
packages/libdata-formvalidator-perl/trunk/lib/Data/FormValidator/Results.pm
packages/libdata-formvalidator-perl/trunk/t/18_constraint_refs.t
packages/libdata-formvalidator-perl/trunk/t/filters_builtin.t
Modified: packages/libdata-formvalidator-perl/trunk/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-formvalidator-perl/trunk/Changes?rev=3081&op=diff
==============================================================================
--- packages/libdata-formvalidator-perl/trunk/Changes (original)
+++ packages/libdata-formvalidator-perl/trunk/Changes Sat Jun 17 15:23:04 2006
@@ -1,3 +1,16 @@
+4.20 Mon Jun 12 20:44:36 EDT 2006
+ [ENHANCEMENTS]
+ - Documentation in Data::FormValidator::Filters has been improved. (Mark Stosberg}
+ - Added FV_split() a new filter that makes it super-easy to apply the same constraint
+ to a list of values passed in a single field, such as a comma separated list of e-mail
+ addresses. (Mark Stosberg).
+
+ [BUG FIXES]
+ - For input given as a hashref containing array references, values could
+ have been mistakenly modified by reference through filters. We now
+ explicitly copy elements in these case, to avoid modifying the input.
+ (RT#19592)
+
4.14 Fri Feb 17 08:59:40 EST 2006
[ENHANCEMENTS]
- Consider a field with only a null character to be invalid (Jamie Krasnoo)
Modified: packages/libdata-formvalidator-perl/trunk/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-formvalidator-perl/trunk/MANIFEST?rev=3081&op=diff
==============================================================================
--- packages/libdata-formvalidator-perl/trunk/MANIFEST (original)
+++ packages/libdata-formvalidator-perl/trunk/MANIFEST Sat Jun 17 15:23:04 2006
@@ -51,6 +51,7 @@
t/dependency_groups.t
t/filter_constraints.t
t/filters_builtin.t
+t/filters_shouldnt_modify.t
t/get_input_data.t
t/missing_optional.t
t/msgs.t
Modified: packages/libdata-formvalidator-perl/trunk/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-formvalidator-perl/trunk/META.yml?rev=3081&op=diff
==============================================================================
--- packages/libdata-formvalidator-perl/trunk/META.yml (original)
+++ packages/libdata-formvalidator-perl/trunk/META.yml Sat Jun 17 15:23:04 2006
@@ -1,6 +1,6 @@
--- #YAML:1.0
name: Data-FormValidator
-version: 4.14
+version: 4.20
author:
- Mark Stosberg <mark at summersault.com>
abstract: |-
@@ -18,7 +18,7 @@
provides:
Data::FormValidator:
file: lib/Data/FormValidator.pm
- version: 4.14
+ version: 4.20
Data::FormValidator::Constraints:
file: lib/Data/FormValidator/Constraints.pm
version: 4.14
@@ -36,7 +36,7 @@
version: 1.4
Data::FormValidator::Filters:
file: lib/Data/FormValidator/Filters.pm
- version: 4
+ version: 4.1
Data::FormValidator::Results:
file: lib/Data/FormValidator/Results.pm
version: 4.14
Modified: packages/libdata-formvalidator-perl/trunk/README
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-formvalidator-perl/trunk/README?rev=3081&op=diff
==============================================================================
--- packages/libdata-formvalidator-perl/trunk/README (original)
+++ packages/libdata-formvalidator-perl/trunk/README Sat Jun 17 15:23:04 2006
@@ -284,7 +284,8 @@
anonymous subroutine which should take one parameter, the field value
and return the (possibly) modified value.
- Filters modify the data, so use them carefully.
+ Filters modify the data returned through the results object, so use them
+ carefully.
See Data::FormValidator::Filters for details on the built-in filters.
@@ -811,16 +812,29 @@
Albrecht to the MiniVend program.
BUGS
+ Bug reports and patches are welcome. Reports which include a failing
+ Test::More style test are helpful will receive priority.
+
<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Data-FormValidator>
CONTRIBUTING
- Patches, questions and feedback are welcome. This project is managed
- using the darcs source control system ( http://www.darcs.net/ ). My
- darcs archive is here: http://mark.stosberg.com/darcs_hive/dfv/
+ This project is managed using the darcs source control system (
+ http://www.darcs.net/ ). My darcs archive is here:
+ http://mark.stosberg.com/darcs_hive/dfv/
+
+ Support Mailing List
+
+ If you have any questions, comments, or feature suggestions, post them
+ to the support mailing list! To join the mailing list, visit
+
+ <http://lists.sourceforge.net/lists/listinfo/cascade-dataform>
+
+ Messages about DFV sent directly to the maintainer may be redirected
+ here.
AUTHOR
- Parts Copyright 2001-2003 by Mark Stosberg <markstos at cpan.org>, (Current
- Maintainer)
+ Parts Copyright 2001-2006 by Mark Stosberg <mark at summersault.com>,
+ (Current Maintainer)
Copyright (c) 1999 Francis J. Lacoste and iNsu Innovations Inc. All
rights reserved. (Original Author)
@@ -829,12 +843,6 @@
Parts Copyright 1996-1999 by Bruce Albrecht
<bruce.albrecht at seag.fingerhut.com>
-
- Support Mailing List
-
- If you have any questions, comments, bug reports or feature suggestions,
- post them to the support mailing list! To join the mailing list, visit
- <http://lists.sourceforge.net/lists/listinfo/cascade-dataform>
LICENSE
This program is free software; you can redistribute it and/or modify it
Modified: packages/libdata-formvalidator-perl/trunk/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-formvalidator-perl/trunk/debian/changelog?rev=3081&op=diff
==============================================================================
--- packages/libdata-formvalidator-perl/trunk/debian/changelog (original)
+++ packages/libdata-formvalidator-perl/trunk/debian/changelog Sat Jun 17 15:23:04 2006
@@ -1,3 +1,11 @@
+libdata-formvalidator-perl (4.20-1) unstable; urgency=low
+
+ * New upstream release.
+ * Set Standards-Version to 3.7.2.
+ * Set Debhelper Compatibility Level to 5.
+
+ -- gregor herrmann <gregor+debian at comodo.priv.at> Sat, 17 Jun 2006 17:18:17 +0200
+
libdata-formvalidator-perl (4.14-1) unstable; urgency=low
* New upstream release
Modified: packages/libdata-formvalidator-perl/trunk/debian/compat
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-formvalidator-perl/trunk/debian/compat?rev=3081&op=diff
==============================================================================
--- packages/libdata-formvalidator-perl/trunk/debian/compat (original)
+++ packages/libdata-formvalidator-perl/trunk/debian/compat Sat Jun 17 15:23:04 2006
@@ -1,1 +1,1 @@
-4
+5
Modified: packages/libdata-formvalidator-perl/trunk/debian/control
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-formvalidator-perl/trunk/debian/control?rev=3081&op=diff
==============================================================================
--- packages/libdata-formvalidator-perl/trunk/debian/control (original)
+++ packages/libdata-formvalidator-perl/trunk/debian/control Sat Jun 17 15:23:04 2006
@@ -2,10 +2,10 @@
Section: perl
Priority: optional
Maintainer: Debian Perl Group <pkg-perl-maintainers at lists.alioth.debian.org>
-Uploaders: Allard Hoeve <allard at byte.nl>, Gunnar Wolf <gwolf at debian.org>, Joachim Breitner <nomeata at debian.org>, Russ Allbery <rra at debian.org>, Niko Tyni <ntyni at iki.fi>
-Build-Depends: debhelper (>> 4.0.0)
+Uploaders: Allard Hoeve <allard at byte.nl>, Gunnar Wolf <gwolf at debian.org>, Joachim Breitner <nomeata at debian.org>, Russ Allbery <rra at debian.org>, Niko Tyni <ntyni at iki.fi>, gregor herrmann <gregor+debian at comodo.priv.at>
+Build-Depends: debhelper (>= 5.0.0)
Build-Depends-Indep: libmodule-build-perl, libregexp-common-perl, libimage-size-perl, libfile-mmagic-perl, libdate-calc-perl, libmime-types-perl, libtest-pod-perl, libcgi-simple-perl, perl-modules, libtemplate-perl
-Standards-Version: 3.6.2
+Standards-Version: 3.7.2
Package: libdata-formvalidator-perl
Architecture: all
Modified: packages/libdata-formvalidator-perl/trunk/lib/Data/FormValidator.pm
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-formvalidator-perl/trunk/lib/Data/FormValidator.pm?rev=3081&op=diff
==============================================================================
--- packages/libdata-formvalidator-perl/trunk/lib/Data/FormValidator.pm (original)
+++ packages/libdata-formvalidator-perl/trunk/lib/Data/FormValidator.pm Sat Jun 17 15:23:04 2006
@@ -31,7 +31,7 @@
use vars qw( $VERSION $AUTOLOAD @ISA @EXPORT_OK %EXPORT_TAGS );
-$VERSION = '4.14';
+$VERSION = '4.20';
require Exporter;
@ISA = qw(Exporter);
@@ -492,9 +492,9 @@
(trim,digit,etc) or an anonymous subroutine which should take one parameter,
the field value and return the (possibly) modified value.
-Filters modify the data, so use them carefully.
-
-See Data::FormValidator::Filters for details on the built-in filters.
+Filters modify the data returned through the results object, so use them carefully.
+
+See L<Data::FormValidator::Filters> for details on the built-in filters.
=head2 field_filters
@@ -1180,17 +1180,29 @@
=head1 BUGS
+Bug reports and patches are welcome. Reports which include a failing Test::More
+style test are helpful will receive priority.
+
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Data-FormValidator>
=head1 CONTRIBUTING
-Patches, questions and feedback are welcome. This project is managed using
-the darcs source control system ( http://www.darcs.net/ ). My darcs archive is here:
+This project is managed using the darcs source control system (
+http://www.darcs.net/ ). My darcs archive is here:
http://mark.stosberg.com/darcs_hive/dfv/
+B<Support Mailing List>
+
+If you have any questions, comments, or feature suggestions, post them to the
+support mailing list! To join the mailing list, visit
+
+L<http://lists.sourceforge.net/lists/listinfo/cascade-dataform>
+
+Messages about DFV sent directly to the maintainer may be redirected here.
+
=head1 AUTHOR
-Parts Copyright 2001-2003 by Mark Stosberg <markstos at cpan.org>, (Current Maintainer)
+Parts Copyright 2001-2006 by Mark Stosberg <mark at summersault.com>, (Current Maintainer)
Copyright (c) 1999 Francis J. Lacoste and iNsu Innovations Inc. All rights reserved.
(Original Author)
@@ -1199,12 +1211,6 @@
Parts Copyright 1996-1999 by Bruce Albrecht <bruce.albrecht at seag.fingerhut.com>
-B<Support Mailing List>
-
-If you have any questions, comments, bug reports or feature suggestions,
-post them to the support mailing list! To join the mailing list, visit
-L<http://lists.sourceforge.net/lists/listinfo/cascade-dataform>
-
=head1 LICENSE
This program is free software; you can redistribute it and/or modify
Modified: packages/libdata-formvalidator-perl/trunk/lib/Data/FormValidator/Filters.pm
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-formvalidator-perl/trunk/lib/Data/FormValidator/Filters.pm?rev=3081&op=diff
==============================================================================
--- packages/libdata-formvalidator-perl/trunk/lib/Data/FormValidator/Filters.pm (original)
+++ packages/libdata-formvalidator-perl/trunk/lib/Data/FormValidator/Filters.pm Sat Jun 17 15:23:04 2006
@@ -1,21 +1,19 @@
-#
# Filters.pm - Common filters for use in Data::FormValidator.
-#
# This file is part of Data::FormValidator.
#
# Author: Francis J. Lacoste <francis.lacoste at iNsu.COM>
+# Maintainer: Mark Stosberg <mark at summersault.com>
#
# Copyright (C) 1999,2000 iNsu Innovations Inc.
#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms same terms as perl itself.
-#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms same terms as perl itself.
package Data::FormValidator::Filters;
use strict;
use vars qw/$AUTOLOAD @ISA @EXPORT_OK %EXPORT_TAGS $VERSION/;
-$VERSION = 4.00;
+$VERSION = 4.1;
require Exporter;
@ISA = qw(Exporter);
@@ -37,6 +35,7 @@
filter_trim
filter_uc
filter_ucfirst
+ FV_split
);
%EXPORT_TAGS = (
@@ -51,24 +50,47 @@
Data::FormValidator::Filters - Basic set of filters available in an Data::FormValidator profile.
-
=head1 SYNOPSIS
use Data::FormValidator;
- my $validator = new Data::FormValidator( "/home/user/input_profiles.pl" );
- my $results = $validator->check( \%fdat, "customer_infos" );
+ %profile = (
+ filters => 'trim',
+ ...
+ );
+
+ my $results = Data::FormValidator->check( \%data, \%profile );
=head1 DESCRIPTION
These are the builtin filters which may be specified as a name in the
-I<filters> and I<field_filters> parameters of the input profile. You may
-also call these functions directly through the procedural interface by
-either importing them directly or importing the whole I<:filters> group. For
-example, if you want to access the I<trim> function directly, you could either do:
+I<filters>, I<field_filters>, and I<field_filter_regexp_map> parameters of the
+input profile.
+
+Filters are applied as the first step of validation, possibily modifying a copy
+of the validation before any constraints are checked.
+
+=head1 RECOMMENDED USE
+
+As a long time maintainer and user of Data::FormValidator, I recommend that
+filters be used with caution. They are immediately modifying the input
+provided, so the original data is lost. The few I recommend include C<trim>,
+which removes leading and trailing whitespace. I have this turned on by default
+by using L<CGI::Application::Plugin::ValidateRM>. It's also generally safe to use
+the C<lc> and C<uc> filters if you need that kind of data transformation.
+
+Beyond simple filters, I recommend transforming the C<"valid"> hash returned
+from validation if further changes are needed.
+
+=head1 PROCEDURAL INTERFACE
+
+You may also call these functions directly through the
+procedural interface by either importing them directly or importing the whole
+I<:filters> group. For example, if you want to access the I<trim> function
+directly, you could either do:
use Data::FormValidator::Filters (qw/filter_trim/);
- or
+ # or
use Data::FormValidator::Filters (qw/:filters/);
$string = filter_trim($string);
@@ -76,9 +98,46 @@
Notice that when you call filters directly, you'll need to prefix the filter name with
"filter_".
-=over
-
-=item trim
+=head1 THE FILTERS
+
+=head2 FV_split
+
+ use Data::FormValidator::Filters qw(FV_split);
+
+ # Validate every e-mail in a comma separated list
+
+ field_filters => {
+ several_emails => FV_split(qr/\s*,\s*/),
+
+ # Any pattern that can be used by the 'split' builtin works.
+ tab_sep_field => FV_split('\t'),
+ },
+ constraint_methods => {
+ several_emails => email(),
+ },
+
+With this filter, you can split a field into multiple values. The constraint for
+the field will then be applied to every value.
+
+This filter has a different naming convention because it is a higher-order
+function. Rather than returning a value directly, it returns a code reference
+to a standard Data::FormValidator filter.
+
+After successfully being validated the values will appear as an arrayref.
+
+=cut
+
+sub FV_split {
+ my $splitter = shift || die "nothing to split on!";
+ return sub {
+ my $value = shift;
+ return undef unless defined $value;
+ my @a = split $splitter, $value;
+ return \@a;
+ };
+}
+
+=head2 trim
Remove white space at the front and end of the fields.
@@ -99,7 +158,7 @@
=pod
-=item strip
+=head2 strip
Runs of white space are replaced by a single space.
@@ -117,7 +176,7 @@
=pod
-=item digit
+=head2 digit
Remove non digits characters from the input.
@@ -134,7 +193,7 @@
=pod
-=item alphanum
+=head2 alphanum
Remove non alphanumerical characters from the input.
@@ -149,7 +208,7 @@
=pod
-=item integer
+=head2 integer
Extract from its input a valid integer number.
@@ -165,9 +224,11 @@
=pod
-=item pos_integer
+=head2 pos_integer
Extract from its input a valid positive integer number.
+
+Bugs: This filter won't extract "9" from "a9+", it will instead extract "9+"
=cut
@@ -181,9 +242,12 @@
=pod
-=item neg_integer
+=head2 neg_integer
Extract from its input a valid negative integer number.
+
+Bugs: This filter will currently filter the case of "a9-" to become "9-",
+which it should leave it alone.
=cut
@@ -197,9 +261,11 @@
=pod
-=item decimal
+=head2 decimal
Extract from its input a valid decimal number.
+
+Bugs: Given "1,000.23", it will currently return "1.000.23"
=cut
@@ -215,9 +281,11 @@
=pod
-=item pos_decimal
+=head2 pos_decimal
Extract from its input a valid positive decimal number.
+
+Bugs: Given "1,000.23", it will currently return "1.000.23"
=cut
@@ -233,9 +301,11 @@
=pod
-=item neg_decimal
+=head2 neg_decimal
Extract from its input a valid negative decimal number.
+
+Bugs: Given "1,000.23", it will currently return "1.000.23"
=cut
@@ -251,9 +321,11 @@
=pod
-=item dollars
+=head2 dollars
Extract from its input a valid number to express dollars like currency.
+
+Bugs: This filter won't currently remove trailing numbers like "1.234".
=cut
@@ -268,7 +340,7 @@
=pod
-=item phone
+=head2 phone
Filters out characters which aren't valid for an phone number. (Only
accept digits [0-9], space, comma, minus, parenthesis, period and pound [#].)
@@ -284,7 +356,7 @@
=pod
-=item sql_wildcard
+=head2 sql_wildcard
Transforms shell glob wildcard (*) to the SQL like wildcard (%).
@@ -299,7 +371,7 @@
=pod
-=item quotemeta
+=head2 quotemeta
Calls the quotemeta (quote non alphanumeric character) builtin on its
input.
@@ -313,7 +385,7 @@
=pod
-=item lc
+=head2 lc
Calls the lc (convert to lowercase) builtin on its input.
@@ -326,7 +398,7 @@
=pod
-=item uc
+=head2 uc
Calls the uc (convert to uppercase) builtin on its input.
@@ -339,7 +411,7 @@
=pod
-=item ucfirst
+=head2 ucfirst
Calls the ucfirst (Uppercase first letter) builtin on its input.
@@ -355,13 +427,9 @@
__END__
-=pod
-
-=back
-
=head1 SEE ALSO
-=over
+=over 4
=item o
Modified: packages/libdata-formvalidator-perl/trunk/lib/Data/FormValidator/Results.pm
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-formvalidator-perl/trunk/lib/Data/FormValidator/Results.pm?rev=3081&op=diff
==============================================================================
--- packages/libdata-formvalidator-perl/trunk/lib/Data/FormValidator/Results.pm (original)
+++ packages/libdata-formvalidator-perl/trunk/lib/Data/FormValidator/Results.pm Sat Jun 17 15:23:04 2006
@@ -1020,7 +1020,14 @@
}
# otherwise, it's already a hash reference
elsif (ref $data eq 'HASH') {
- return %$data;
+ # be careful to actually copy array references
+ my %copy = %$data;
+ for (grep { ref $data->{$_} eq 'ARRAY' } keys %$data) {
+ my @array_copy = @{ $data->{$_} };
+ $copy{$_} = \@array_copy;
+ }
+
+ return %copy;
}
else {
die "Data::FormValidator->validate() or check() called with invalid input data structure.";
Modified: packages/libdata-formvalidator-perl/trunk/t/18_constraint_refs.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-formvalidator-perl/trunk/t/18_constraint_refs.t?rev=3081&op=diff
==============================================================================
--- packages/libdata-formvalidator-perl/trunk/t/18_constraint_refs.t (original)
+++ packages/libdata-formvalidator-perl/trunk/t/18_constraint_refs.t Sat Jun 17 15:23:04 2006
@@ -51,7 +51,7 @@
eval {
($valids, $missings, $invalids, $unknowns) = $validator->validate({ email => 'invalid'}, 'default');
};
-ok(not $@);
+is($@,'','survived eval');
is($invalids->[0]->[0], 'email');
is($invalids->[0]->[1], 'Your email address is invalid.');
Modified: packages/libdata-formvalidator-perl/trunk/t/filters_builtin.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-formvalidator-perl/trunk/t/filters_builtin.t?rev=3081&op=diff
==============================================================================
--- packages/libdata-formvalidator-perl/trunk/t/filters_builtin.t (original)
+++ packages/libdata-formvalidator-perl/trunk/t/filters_builtin.t Sat Jun 17 15:23:04 2006
@@ -1,5 +1,14 @@
use Test::More qw/no_plan/;
use Data::FormValidator::Filters (qw/:filters/);
+use strict;
+
+{
+ my $comma_splitter = FV_split(',');
+ is_deeply( $comma_splitter->('a,b'), [qw/a b/], "FV_split with two values");
+ is_deeply( $comma_splitter->('a'), [qw/a/], "FV_split with one value");
+ is_deeply( $comma_splitter->(),undef, "FV_split with no values");
+}
+
is( filter_dollars('There is $0.11e money in here somewhere'),
'0.11',
@@ -17,11 +26,11 @@
is( filter_pos_integer('a9+'),
'9',
- "filter_pos_integer should car which side a + is on.");
+ "filter_pos_integer should care which side a + is on.");
is( filter_integer('a9+'),
'9',
- "filter_integer should car which side a + is on.");
+ "filter_integer should care which side a + is on.");
is( filter_decimal('1,000.23'),
'1000.23',
More information about the Pkg-perl-cvs-commits
mailing list