NAME

CGI::Application::Plugin::FormValidator::Simple - Validator for CGI::Application with FormValidator::Simple

SYNOPSIS

use CGI::Application::Plugin::FormValidator::Simple;

$self->validator(
    plugins => [ 'Japanese', 'Number::Phone::JP' ],
    options => {
        charset => 'euc',
    },
    messages => {
        user => {
            param1 => {
                NOT_BLANK => 'Input name!',
                ASCII     => 'Input name with ascii code!',
            },
            mail1 => {
                DEFAULT   => 'email is wrong.!',
                NOT_BLANK => 'input email.!'
            },
        },
        company => {
            param1 => {
                NOT_BLANK => 'Input name!',
            },
        },
    },
);

$self->form(
    param1 => [qw/NOT_BLANK ASCII/, [qw/LENGTH 4 10/]],
    param2 => [qw/NOT_BLANK/, [qw/JLENGTH 4 10/]],
    mail1  => [qw/NOT_BLANK EMAIL_LOOSE/],
    mail2  => [qw/NOT_BLANK EMAIL_LOOSE/],
    { mail => [qw/mail1 mail2/] } => ['DUPLICATION'],
);

print $self->form->valid('param1');

if ( some condition... ) {
    $self->form(
        other_param => [qw/NOT_INT/],
    );
}

if ( $self->form->has_missing || $self->form->has_invalid ) {
    if ( $self->form->missing('param1') ) {
        ...
    }

    if ( $self->form->invalid( param1 => 'ASCII' ) ) {
        ...
    }

    if ( $self->form->invalid( param3 => 'MY_ERROR' ) ) {
        ...
    }

}

DESCRIPTION

This plugin for CGI::Application allows you to validate request parameters with FormValidator::Simple. See FormValidator::Simple for more information.

SEE ALSO

FormValidator::Simple

Catalyst::Plugin::FormValidator::Simple

CGI::Application

AUTHOR

Gosuke Miyashita, <gosukenator@gmail.com>

COPYRIGHT AND LICENSE

Copyright (C) 2005 by Gosuke Miyashita

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.5 or, at your option, any later version of Perl 5 you may have available.