Catalyst::Plugin::FormValidator::Simple::OwnCheck - Validator for Catalyst with FormValidator::Simple
use Catalyst qw/FormValidator::Simple::OwnCheck FillInForm/; # set option MyApp->config->{validator} = { plugins => ['CreditCard', 'Japanese'], plugins_owncheck => ['MyApp::Checker'], options => { charset => 'euc'}, }
in your Checker.pm
package MyApp::Checker; use strict; use FormValidator::Simple::Exception; use FormValidator::Simple::Constants; our $VERSION = '0.01'; sub NUMBER { my ( $self, $params, $args ) = @_; my $is_number = $params->[0] =~ m{^\d+$} ? 1 : 0; return $is_number ? TRUE : FALSE; } 1;
in your controller
sub defaulti : Private { my ($self, $c) = @_; #this will check the param1 whether is NOT_BLANK and is NUMBER $c->form( param1 => [ qw/NOT_BLANK/, 'NUMBER' ], ); #... }
This plugin allows you to validate request parameters with a checker of your application namespace , no need to package your checker in the namespace of FormValidator::Simple. See FormValidator::Simple for more information.
This behaves like as Catalyst::Plugin::FormValidator.
FormValidator::Simple
Catalyst
ADONG <lt>dxluo83@gmail.com<gt>
Copyright(C) 2006 by ADONG
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Catalyst::Plugin::FormValidator::Simple::OwnCheck, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Catalyst::Plugin::FormValidator::Simple::OwnCheck
CPAN shell
perl -MCPAN -e shell install Catalyst::Plugin::FormValidator::Simple::OwnCheck
For more information on module installation, please visit the detailed CPAN module installation guide.