From 0ea752f3f43e17c91e2c7938b53481d281fd9d9c Mon Sep 17 00:00:00 2001 From: delphinus35 Date: Sun, 2 Sep 2012 12:52:47 +0900 Subject: [PATCH 1/2] added markdown --- Makefile.PL | 2 +- README.mkdn | 100 +++++++++++++++++++ lib/Amon2/Plugin/Web/FormValidator/Simple.pm | 6 +- 3 files changed, 104 insertions(+), 4 deletions(-) create mode 100644 README.mkdn diff --git a/Makefile.PL b/Makefile.PL index 3f2175e..bedb77c 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -11,5 +11,5 @@ author_tests 'xt'; test_requires 'Test::More'; auto_set_repository; auto_include; -readme_from 'lib/Amon2/Plugin/Web/FormValidator/Simple.pm'; +readme_markdown_from 'lib/Amon2/Plugin/Web/FormValidator/Simple.pm' => 'clean'; WriteAll; diff --git a/README.mkdn b/README.mkdn new file mode 100644 index 0000000..9d4f5fa --- /dev/null +++ b/README.mkdn @@ -0,0 +1,100 @@ +# NAME + +Amon2::Plugin::Web::FormValidator::Simple - Amon2 plugin + +# SYNOPSIS + + # MyApp.pm + + __PACKAGE__->load_plugins('Web::FormValidator::Simple'); + + # MyApp/Web/Dispatcher.pm + + get '/user/{team}/{name}/' => sub { + my ($c) = @_; + + # do validate + $c->form( + team => [qw!NOT_BLANK!, [qw!LENGTH 1 10!]], + name => [qw!NOT_BLANK!, [qw!LENGTH 1 10!]], + ); + + # if detect errors, return with a error page. + if ($c->form->has_error) { + return $c->render('error.tt'); + } + + ... + }; + + # same as C::P::FV::S, you can use messages/messages.yml + + # development.pl + ... + + +{ + ... + + validator => +{ + message_format => '

%s

', + message_decode_from => 'UTF-8', + # messages => 'messages.yml', + messages => +{ + account => +{ + team => +{ + NOT_BLANK => 'TEAM cannot be blank!', + LENGTH => 'TEAM length must be [1, 10]', + }, + name => +{ + NOT_BLANK => 'NAME cannnot be blank!', + LENGTH => 'NAME length must be [1, 10]', + }, + }, + }, + }, + }; + + # messages.yml + + account: + team: + NOT_BLANK: TEAM cannot be blank! + LENGTH: TEAM length must be [1, 10] + name: + NOT_BLANK: NAME cannot be blank! + LENGTH: NAME length must be [1, 10] + +# DESCRIPTION + +Amon2::Plugin::Web::FormValidator::Simple is a port of +[Catalyst::Plugin::FormValidator::Simple](http://search.cpan.org/perldoc?Catalyst::Plugin::FormValidator::Simple). +This module has the same methods and options, so see her documents. + +# METHODS + +- `$c->init()` + +initial setup. + +- `$c->form()` + +validate form/query parameters. + +- `$c->set_invalid_form()` + +set error from manual validation. + +# AUTHOR + +JINNOUCHI Yasushi + +# SEE ALSO + +[Amon2::Web](http://search.cpan.org/perldoc?Amon2::Web) +[FormValidator::Simple](http://search.cpan.org/perldoc?FormValidator::Simple) +[Catalyst::Plugin::FormValidator::Simple](http://search.cpan.org/perldoc?Catalyst::Plugin::FormValidator::Simple) + +# LICENSE + +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself. diff --git a/lib/Amon2/Plugin/Web/FormValidator/Simple.pm b/lib/Amon2/Plugin/Web/FormValidator/Simple.pm index ca57dda..51c88c6 100644 --- a/lib/Amon2/Plugin/Web/FormValidator/Simple.pm +++ b/lib/Amon2/Plugin/Web/FormValidator/Simple.pm @@ -128,15 +128,15 @@ This module has the same methods and options, so see her documents. =over 4 -=item $c->init() +=item C<< $c->init() >> initial setup. -=item $c->form() +=item C<< $c->form() >> validate form/query parameters. -=item $c->set_invalid_form() +=item C<< $c->set_invalid_form() >> set error from manual validation. From 042fe6beb438b51e7219152f2084284b0df8eecf Mon Sep 17 00:00:00 2001 From: delphinus35 Date: Sun, 2 Sep 2012 12:58:36 +0900 Subject: [PATCH 2/2] type --- README.mkdn | 2 +- lib/Amon2/Plugin/Web/FormValidator/Simple.pm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.mkdn b/README.mkdn index 9d4f5fa..836c7e5 100644 --- a/README.mkdn +++ b/README.mkdn @@ -13,7 +13,7 @@ Amon2::Plugin::Web::FormValidator::Simple - Amon2 plugin get '/user/{team}/{name}/' => sub { my ($c) = @_; - # do validate + # do validation $c->form( team => [qw!NOT_BLANK!, [qw!LENGTH 1 10!]], name => [qw!NOT_BLANK!, [qw!LENGTH 1 10!]], diff --git a/lib/Amon2/Plugin/Web/FormValidator/Simple.pm b/lib/Amon2/Plugin/Web/FormValidator/Simple.pm index 51c88c6..a7ff7f0 100644 --- a/lib/Amon2/Plugin/Web/FormValidator/Simple.pm +++ b/lib/Amon2/Plugin/Web/FormValidator/Simple.pm @@ -67,7 +67,7 @@ Amon2::Plugin::Web::FormValidator::Simple - Amon2 plugin get '/user/{team}/{name}/' => sub { my ($c) = @_; - # do validate + # do validation $c->form( team => [qw!NOT_BLANK!, [qw!LENGTH 1 10!]], name => [qw!NOT_BLANK!, [qw!LENGTH 1 10!]],