[Catalyst-commits] r12871 - in trunk/Catalyst-Plugin-FormValidator:
. lib lib/Catalyst lib/Catalyst/Plugin t t/lib t/lib/TestApp
t/lib/TestApp/Controller
dhoss at dev.catalyst.perl.org
dhoss at dev.catalyst.perl.org
Mon Feb 15 21:13:32 GMT 2010
Author: dhoss
Date: 2010-02-15 21:13:31 +0000 (Mon, 15 Feb 2010)
New Revision: 12871
Added:
trunk/Catalyst-Plugin-FormValidator/lib/
trunk/Catalyst-Plugin-FormValidator/lib/Catalyst/
trunk/Catalyst-Plugin-FormValidator/lib/Catalyst/Plugin/
trunk/Catalyst-Plugin-FormValidator/lib/Catalyst/Plugin/FormValidator.pm
trunk/Catalyst-Plugin-FormValidator/t/lib/
trunk/Catalyst-Plugin-FormValidator/t/lib/TestApp.pm
trunk/Catalyst-Plugin-FormValidator/t/lib/TestApp/
trunk/Catalyst-Plugin-FormValidator/t/lib/TestApp/Controller/
trunk/Catalyst-Plugin-FormValidator/t/lib/TestApp/Controller/Root.pm
Removed:
trunk/Catalyst-Plugin-FormValidator/FormValidator.pm
Modified:
trunk/Catalyst-Plugin-FormValidator/Changes
trunk/Catalyst-Plugin-FormValidator/META.yml
trunk/Catalyst-Plugin-FormValidator/Makefile.PL
Log:
updated changelog, moosified, reorganized, added basic test
Modified: trunk/Catalyst-Plugin-FormValidator/Changes
===================================================================
--- trunk/Catalyst-Plugin-FormValidator/Changes 2010-02-15 19:46:44 UTC (rev 12870)
+++ trunk/Catalyst-Plugin-FormValidator/Changes 2010-02-15 21:13:31 UTC (rev 12871)
@@ -1,5 +1,8 @@
Revision history for Perl extension Catalyst::Plugin::FormValidator.
+0.05 Mon Feb 15 13:35:00 2010
+ - removed NEXT
+ - turned into Moose::Role
0.04 Thu Apr 2 18:45:00 2009
- Add deprecation notice
- Added quotes on prereq.
Deleted: trunk/Catalyst-Plugin-FormValidator/FormValidator.pm
===================================================================
--- trunk/Catalyst-Plugin-FormValidator/FormValidator.pm 2010-02-15 19:46:44 UTC (rev 12870)
+++ trunk/Catalyst-Plugin-FormValidator/FormValidator.pm 2010-02-15 21:13:31 UTC (rev 12871)
@@ -1,102 +0,0 @@
-package Catalyst::Plugin::FormValidator;
-
-use strict;
-use NEXT;
-use Data::FormValidator;
-
-our $VERSION = '0.03';
-
-=head1 NAME
-
-DEPRECATED - Catalyst::Plugin::FormValidator - Unmaintained Data::FormValidator
-plugin for Catalyst.
-
-=head1 SYNOPSIS
-
- use Catalyst 'FormValidator';
-
- $c->form( optional => ['rest'] );
- print $c->form->valid('rest');
-
-=head1 WARNING
-
-This code is not maintained, and is disrecommended for use in new applications.
-
-Instead, it is recommended to use newer, better supported modules such as:
-
-=over
-
-=item L<Catalyst::Controller::HTML::FormFu>
-
-=item L<Catalyst::Controller::FormBuilder>
-
-=back
-
-Note that not only is this plugin disrecommended (as it takes over the global
-C<< $c->form >> method, rather than being applyable in only part of your
-application), but L<Data::FormValidator> itself is not recommended for use.
-
-=head1 DESCRIPTION
-
-This plugin uses L<Data::FormValidator> to validate and set up form data
-from your request parameters. It's a quite thin wrapper around that
-module, so most of the relevant information can be found there.
-
-=head2 EXTENDED METHODS
-
-=head3 prepare
-
-Sets up $c->{form}
-
-=cut
-
-sub prepare {
- my $c = shift;
- $c = $c->NEXT::prepare(@_);
- $c->{form} = Data::FormValidator->check( $c->request->parameters, {} );
- return $c;
-}
-
-=head2 METHODS
-
-=head3 form
-
-Merge values with FormValidator.
-
- $c->form( required => ['yada'] );
-
-Returns a L<Data::FormValidator::Results> object.
-
- $c->form->valid('rest');
-
-The actual parameters sent to $c->form are the same as the profile in
-L<Data::FormValidator>'s check function.
-
-=cut
-
-sub form {
- my $c = shift;
- if ( $_[0] ) {
- my $form = $_[1] ? {@_} : $_[0];
- $c->{form} =
- Data::FormValidator->check( $c->request->parameters, $form );
- }
- return $c->{form};
-}
-
-=head1 SEE ALSO
-
-L<Catalyst>, L<Data::FormValidator>
-
-=head1 AUTHOR
-
-Sebastian Riedel, C<sri at cpan.org>
-
-=head1 COPYRIGHT
-
-This program is free software, you can redistribute it and/or modify it under
-the same terms as Perl itself.
-
-=cut
-
-1;
Modified: trunk/Catalyst-Plugin-FormValidator/META.yml
===================================================================
--- trunk/Catalyst-Plugin-FormValidator/META.yml 2010-02-15 19:46:44 UTC (rev 12870)
+++ trunk/Catalyst-Plugin-FormValidator/META.yml 2010-02-15 21:13:31 UTC (rev 12871)
@@ -1,11 +1,11 @@
# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: Catalyst-Plugin-FormValidator
-version: 0.02
+version: 0.05
version_from: FormValidator.pm
installdirs: site
requires:
- Catalyst: 2.99
+ Catalyst: 5.8
Data::FormValidator: 0
distribution_type: module
Modified: trunk/Catalyst-Plugin-FormValidator/Makefile.PL
===================================================================
--- trunk/Catalyst-Plugin-FormValidator/Makefile.PL 2010-02-15 19:46:44 UTC (rev 12870)
+++ trunk/Catalyst-Plugin-FormValidator/Makefile.PL 2010-02-15 21:13:31 UTC (rev 12871)
@@ -4,7 +4,7 @@
NAME => 'Catalyst::Plugin::FormValidator',
AUTHOR => 'Sebastian Riedel (sri at oook.de)',
PREREQ_PM => {
- Catalyst => '2.99',
+ Catalyst => '5.8',
'Data::FormValidator' => 0
},
VERSION_FROM => 'FormValidator.pm'
Added: trunk/Catalyst-Plugin-FormValidator/lib/Catalyst/Plugin/FormValidator.pm
===================================================================
--- trunk/Catalyst-Plugin-FormValidator/lib/Catalyst/Plugin/FormValidator.pm (rev 0)
+++ trunk/Catalyst-Plugin-FormValidator/lib/Catalyst/Plugin/FormValidator.pm 2010-02-15 21:13:31 UTC (rev 12871)
@@ -0,0 +1,88 @@
+package Catalyst::Plugin::FormValidator;
+
+use Moose::Role;
+use Data::FormValidator;
+
+our $VERSION = '0.05';
+$VERSION = eval $VERSION;
+
+has 'form' => (
+ is => 'ro',
+ required => 1,
+ lazy_build => 1,
+);
+
+sub _build_form {
+ my $self = shift;
+ my $c = $self->context_class;
+ return Data::FormValidator->check( $c->request->parameters, {} );
+}
+
+=head1 NAME
+
+Catalyst::Plugin::FormValidator - Data::FormValidator
+plugin for Catalyst.
+
+=head1 SYNOPSIS
+
+ use Catalyst 'FormValidator';
+
+ $c->form( optional => ['rest'] );
+ print $c->form->valid('rest');
+
+
+Note that not only is this plugin disrecommended (as it takes over the global
+C<< $c->form >> method, rather than being applyable in only part of your
+application), but L<Data::FormValidator> itself is not recommended for use.
+
+=head1 DESCRIPTION
+
+This plugin uses L<Data::FormValidator> to validate and set up form data
+from your request parameters. It's a quite thin wrapper around that
+module, so most of the relevant information can be found there.
+
+=head2 EXTENDED METHODS
+
+=head2 METHODS
+
+=head3 form
+
+Merge values with FormValidator.
+
+ $c->form( required => ['yada'] );
+
+Returns a L<Data::FormValidator::Results> object.
+
+ $c->form->valid('rest');
+
+The actual parameters sent to $c->form are the same as the profile in
+L<Data::FormValidator>'s check function.
+
+=cut
+
+ sub form {
+ my $c = shift;
+ if ( $_[0] ) {
+ my $form = $_[1] ? {@_} : $_[0];
+ $c->{form} =
+ Data::FormValidator->check( $c->request->parameters, $form );
+ }
+ return $c->{form};
+}
+
+=head1 SEE ALSO
+
+L<Catalyst>, L<Data::FormValidator>
+
+=head1 AUTHOR
+
+Sebastian Riedel, C<sri at cpan.org>
+
+=head1 COPYRIGHT
+
+This program is free software, you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
+=cut
+
+1;
Added: trunk/Catalyst-Plugin-FormValidator/t/lib/TestApp/Controller/Root.pm
===================================================================
--- trunk/Catalyst-Plugin-FormValidator/t/lib/TestApp/Controller/Root.pm (rev 0)
+++ trunk/Catalyst-Plugin-FormValidator/t/lib/TestApp/Controller/Root.pm 2010-02-15 21:13:31 UTC (rev 12871)
@@ -0,0 +1,19 @@
+package TestApp::Controller::Root;
+use Moose;
+use namespace::autoclean;
+
+BEGIN { extends 'Catalyst::Controller' }
+
+__PACKAGE__->config(namespace => '');
+
+sub form_test : Local{
+ my ($self, $c) = @_;
+ $c->res->body(qq{
+ <form name="test" action="POST">
+ <input type="text" name="testinput" />
+ <input type="submit" name="press" />
+ </form>
+ });
+}
+
+__PACKAGE__->meta->make_immutable;
\ No newline at end of file
Added: trunk/Catalyst-Plugin-FormValidator/t/lib/TestApp.pm
===================================================================
--- trunk/Catalyst-Plugin-FormValidator/t/lib/TestApp.pm (rev 0)
+++ trunk/Catalyst-Plugin-FormValidator/t/lib/TestApp.pm 2010-02-15 21:13:31 UTC (rev 12871)
@@ -0,0 +1,12 @@
+package # Hide from PAUSE
+ TestApp;
+use Moose;
+use namespace::autoclean;
+
+use Catalyst::Runtime 5.80;
+use Catalyst qw/
+ FormValidator
+ /;
+extends 'Catalyst';
+TestApp->setup;
+__PACKAGE__->meta->make_immutable;
\ No newline at end of file
More information about the Catalyst-commits
mailing list