Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/markdown-readme' into develop
- Loading branch information
Showing
3 changed files
with
105 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 validation | ||
$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 => '<p>%s</p>', | ||
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 <delphinus@remora.cx> | ||
|
||
# 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters