r2779 - in /packages/libformvalidator-simple-perl/trunk: Changes
META.yml
Makefile.PL debian/changelog debian/control lib/FormValidator/Simple.pm
lib/FormValidator/Simple/Validator.pm t/26_inarray.t
eloy at users.alioth.debian.org
eloy at users.alioth.debian.org
Mon May 22 12:24:48 UTC 2006
Author: eloy
Date: Mon May 22 12:24:47 2006
New Revision: 2779
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=2779
Log:
eloy: new upstream version
Modified:
packages/libformvalidator-simple-perl/trunk/Changes
packages/libformvalidator-simple-perl/trunk/META.yml
packages/libformvalidator-simple-perl/trunk/Makefile.PL
packages/libformvalidator-simple-perl/trunk/debian/changelog
packages/libformvalidator-simple-perl/trunk/debian/control
packages/libformvalidator-simple-perl/trunk/lib/FormValidator/Simple.pm
packages/libformvalidator-simple-perl/trunk/lib/FormValidator/Simple/Validator.pm
packages/libformvalidator-simple-perl/trunk/t/26_inarray.t
Modified: packages/libformvalidator-simple-perl/trunk/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libformvalidator-simple-perl/trunk/Changes?rev=2779&op=diff
==============================================================================
--- packages/libformvalidator-simple-perl/trunk/Changes (original)
+++ packages/libformvalidator-simple-perl/trunk/Changes Mon May 22 12:24:47 2006
@@ -1,4 +1,12 @@
Revision history for Perl extension FormValidator::Simple.
+
+0.16 Tue May 16 10:19:00 2006
+ - added DATETIME_FORMAT and DATETIME_STRPTIME validation
+ Thanks to Masahiro Nagano and fbis.
+
+ new sample for IN_ARRAY on POD
+ bugfix: IN_ARRAY didn't work well with numeric arguments.
+ Thanks to ISLUE
0.15 Mon Apr 24 11:51:00 2006
- added IN_ARRAY validation
Modified: packages/libformvalidator-simple-perl/trunk/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libformvalidator-simple-perl/trunk/META.yml?rev=2779&op=diff
==============================================================================
--- packages/libformvalidator-simple-perl/trunk/META.yml (original)
+++ packages/libformvalidator-simple-perl/trunk/META.yml Mon May 22 12:24:47 2006
@@ -1,7 +1,7 @@
# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: FormValidator-Simple
-version: 0.14
+version: 0.16
version_from: lib/FormValidator/Simple.pm
installdirs: site
requires:
@@ -9,13 +9,15 @@
Class::Data::Inheritable: 0.04
Class::Inspector: 1.13
Date::Calc: 5.4
+ DateTime::Format::Strptime: 1.07
Email::Valid: 0.15
Email::Valid::Loose: 0.04
List::MoreUtils: 0.16
Mail::Address: 0
+ Scalar::Util: 0
Tie::IxHash: 1.21
UNIVERSAL::require: 0.1
YAML: 0.39
distribution_type: module
-generated_by: ExtUtils::MakeMaker version 6.29
+generated_by: ExtUtils::MakeMaker version 6.17
Modified: packages/libformvalidator-simple-perl/trunk/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libformvalidator-simple-perl/trunk/Makefile.PL?rev=2779&op=diff
==============================================================================
--- packages/libformvalidator-simple-perl/trunk/Makefile.PL (original)
+++ packages/libformvalidator-simple-perl/trunk/Makefile.PL Mon May 22 12:24:47 2006
@@ -3,18 +3,19 @@
NAME => 'FormValidator::Simple',
VERSION_FROM => 'lib/FormValidator/Simple.pm', # finds $VERSION
PREREQ_PM => {
- 'Class::Accessor' => 0.22,
- 'Class::Inspector' => 1.13,
- 'Class::Data::Inheritable' => 0.04,
- 'UNIVERSAL::require' => 0.10,
- 'Mail::Address' => 0,
- 'Email::Valid' => 0.15,
- 'Email::Valid::Loose' => 0.04,
- 'Date::Calc' => 5.4,
- 'Tie::IxHash' => 1.21,
- 'YAML' => 0.39,
- 'List::MoreUtils' => 0.16,
- 'Scalar::Util' => 0,
+ 'Class::Accessor' => 0.22,
+ 'Class::Inspector' => 1.13,
+ 'Class::Data::Inheritable' => 0.04,
+ 'UNIVERSAL::require' => 0.10,
+ 'Mail::Address' => 0,
+ 'Email::Valid' => 0.15,
+ 'Email::Valid::Loose' => 0.04,
+ 'Date::Calc' => 5.4,
+ 'Tie::IxHash' => 1.21,
+ 'YAML' => 0.39,
+ 'List::MoreUtils' => 0.16,
+ 'Scalar::Util' => 0,
+ 'DateTime::Format::Strptime' => 1.0700,
}, # e.g., Module::Name => 1.1
);
Modified: packages/libformvalidator-simple-perl/trunk/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libformvalidator-simple-perl/trunk/debian/changelog?rev=2779&op=diff
==============================================================================
--- packages/libformvalidator-simple-perl/trunk/debian/changelog (original)
+++ packages/libformvalidator-simple-perl/trunk/debian/changelog Mon May 22 12:24:47 2006
@@ -1,3 +1,11 @@
+libformvalidator-simple-perl (0.16-1) unstable; urgency=low
+
+ * New upstream release
+ * debian/control:
+ - Standards-Version: increased to 3.7.2 without additional changes
+
+ -- Krzysztof Krzyzaniak (eloy) <eloy at debian.org> Mon, 22 May 2006 14:22:30 +0200
+
libformvalidator-simple-perl (0.15-1) unstable; urgency=low
* New upstream release
Modified: packages/libformvalidator-simple-perl/trunk/debian/control
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libformvalidator-simple-perl/trunk/debian/control?rev=2779&op=diff
==============================================================================
--- packages/libformvalidator-simple-perl/trunk/debian/control (original)
+++ packages/libformvalidator-simple-perl/trunk/debian/control Mon May 22 12:24:47 2006
@@ -5,7 +5,7 @@
Build-Depends-Indep: perl (>= 5.8.0-7), libtest-pod-perl, libyaml-perl, libemail-valid-loose-perl, libtie-ixhash-perl, libclass-accessor-perl, libdate-calc-perl, libclass-data-inheritable-perl, libclass-inspector-perl, libmailtools-perl, libuniversal-exports-perl, liblist-moreutils-perl
Maintainer: Debian Perl Group <pkg-perl-maintainers at lists.alioth.debian.org>
Uploaders: Krzysztof Krzyzaniak (eloy) <eloy at debian.org>
-Standards-Version: 3.6.2
+Standards-Version: 3.7.2
Package: libformvalidator-simple-perl
Architecture: all
Modified: packages/libformvalidator-simple-perl/trunk/lib/FormValidator/Simple.pm
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libformvalidator-simple-perl/trunk/lib/FormValidator/Simple.pm?rev=2779&op=diff
==============================================================================
--- packages/libformvalidator-simple-perl/trunk/lib/FormValidator/Simple.pm (original)
+++ packages/libformvalidator-simple-perl/trunk/lib/FormValidator/Simple.pm Mon May 22 12:24:47 2006
@@ -11,7 +11,7 @@
use FormValidator::Simple::Constants;
use FormValidator::Simple::Messages;
-our $VERSION = '0.15';
+our $VERSION = '0.16';
__PACKAGE__->mk_accessors(qw/data prof results/);
@@ -468,6 +468,29 @@
{ datetime => [qw/year month day hour min sec/] } => ['DATETIME']
] );
+=item DATETIME_STRPTIME
+
+check with L<DateTime::Format::Strptime>.
+
+ my $q = CGI->new;
+ $q->param( datetime => '2006-04-26T19:09:21+0900' );
+
+ my $result = FormValidator::Simple->check( $q => [
+ datetime => [ [ 'DATETIME_STRPTIME', '%Y-%m-%dT%T%z' ] ],
+ ] );
+
+=item DATETIME_FORMAT
+
+check with DateTime::Format::***. for example, L<DateTime::Format::HTTP>,
+L<DateTime::Format::Mail>, L<DateTime::Format::MySQL> and etc.
+
+ my $q = CGI->new;
+ $q->param( datetime => '2004-04-26 19:09:21' );
+
+ my $result = FormValidator::Simple->check( $q => [
+ datetime => [ [qw/DATETIME_FORMAT MySQL/] ],
+ ] );
+
=item GREATER_THAN
numeric comparison
@@ -507,6 +530,16 @@
my $result = FormValidator::Simple->check( $q => [
{ some_data => [qw/param1 param2 param3/] } => ['ANY']
] );
+
+=back
+
+=item IN_ARRAY
+
+check if the food ordered is in menu
+
+ my $result = FormValidator::Simple->check( $q => [
+ food => [ ['IN_ARRAY', qw/noodle soba spaghetti/] ],
+ ] };
=back
Modified: packages/libformvalidator-simple-perl/trunk/lib/FormValidator/Simple/Validator.pm
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libformvalidator-simple-perl/trunk/lib/FormValidator/Simple/Validator.pm?rev=2779&op=diff
==============================================================================
--- packages/libformvalidator-simple-perl/trunk/lib/FormValidator/Simple/Validator.pm (original)
+++ packages/libformvalidator-simple-perl/trunk/lib/FormValidator/Simple/Validator.pm Mon May 22 12:24:47 2006
@@ -9,6 +9,7 @@
use Date::Calc;
use UNIVERSAL::require;
use List::MoreUtils;
+use DateTime::Format::Strptime;
__PACKAGE__->mk_classdata( options => { } );
@@ -310,8 +311,63 @@
sub IN_ARRAY {
my ($class, $params, $args) = @_;
- my $data = $params->[0] || '';
+ my $data = defined $params->[0] ? $params->[0] : '';
return (List::MoreUtils::any { $_ eq $data } @$args) ? TRUE : FALSE;
+}
+
+sub DATETIME_FORMAT {
+ my ( $self, $params, $args ) = @_;
+ my $date = $params->[0];
+ my $format = $args->[0];
+ FormValidator::Simple::Exception->throw(
+ qq/Validation DATETIME_FORMAT needs a format argument./)
+ unless $format;
+
+ my $module;
+ if ( ref $format ) {
+ $module = $format;
+ }
+ else {
+ $module = "DateTime::Format::$format";
+ $module->require
+ or FormValidator::Simple::Exception->throw(
+ qq/Validation DATETIME_FORMAT: failed to require $module. "$@"/ );
+ }
+ my $dt;
+ eval {
+ $dt = $module->parse_datetime($date);
+ };
+ my $result = $dt ? TRUE : FALSE;
+
+ if ( $dt && $self->options->{time_zone} ) {
+ $dt->set_time_zone( $self->options->{time_zone} );
+ }
+ return ($result, $dt);
+}
+
+sub DATETIME_STRPTIME {
+ my ( $self, $params, $args ) = @_;
+ my $date = $params->[0];
+ my $format = $args->[0];
+ FormValidator::Simple::Exception->throw(
+ qq/Validation DATETIME_STRPTIME needs a format argument./)
+ unless $format;
+
+ my $dt;
+ eval{
+ my $strp = DateTime::Format::Strptime->new(
+ pattern => $format,
+ on_error => 'croak'
+ );
+ $dt = $strp->parse_datetime($date);
+ };
+
+ my $result = $dt ? TRUE : FALSE;
+
+ if ( $dt && $self->options->{time_zone} ) {
+ $dt->set_time_zone( $self->options->{time_zone} );
+ }
+ return ($result, $dt);
}
1;
Modified: packages/libformvalidator-simple-perl/trunk/t/26_inarray.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libformvalidator-simple-perl/trunk/t/26_inarray.t?rev=2779&op=diff
==============================================================================
--- packages/libformvalidator-simple-perl/trunk/t/26_inarray.t (original)
+++ packages/libformvalidator-simple-perl/trunk/t/26_inarray.t Mon May 22 12:24:47 2006
@@ -1,5 +1,5 @@
use strict;
-use Test::More tests => 3;
+use Test::More tests => 4;
BEGIN{ use_ok("FormValidator::Simple") }
@@ -8,11 +8,14 @@
my $q = CGI->new;
$q->param( foo => 'foo' );
$q->param( bar => 'bar' );
+$q->param( buz => 0 );
my $r = FormValidator::Simple->check( $q => [
foo => [ [qw/IN_ARRAY foo bar buz/] ],
bar => [ [qw/IN_ARRAY foo buz/] ],
+ buz => [ [qw/IN_ARRAY 0 1/] ],
] );
ok(!$r->invalid('foo'));
ok($r->invalid('bar'));
+ok(!$r->invalid('buz'));
More information about the Pkg-perl-cvs-commits
mailing list