Catalyst::Plugin::FormValidator - Data::FormValidator


Catalyst-Plugin-FormValidator documentation Contained in the Catalyst-Plugin-FormValidator distribution.

Index


Code Index:

prepare

Override Catalyst's prepare

form

$c->form object

NAME

Top

Catalyst::Plugin::FormValidator - Data::FormValidator plugin for Catalyst.

SYNOPSIS

Top

    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->form method, rather than being applyable in only part of your application), but Data::FormValidator itself is not recommended for use.

DESCRIPTION

Top

This plugin uses 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.

EXTENDED METHODS

METHODS

form

Merge values with FormValidator.

    $c->form( required => ['yada'] );

Returns a Data::FormValidator::Results object.

    $c->form->valid('rest');

The actual parameters sent to $c->form are the same as the profile in Data::FormValidator's check function.

SEE ALSO

Top

Catalyst, Data::FormValidator

AUTHOR

Top

Sebastian Riedel, sri@cpan.org

CONTRIBUTORS

Top

Devin Austin (dhoss@cpan.org)

COPYRIGHT

Top


Catalyst-Plugin-FormValidator documentation Contained in the Catalyst-Plugin-FormValidator distribution.
package Catalyst::Plugin::FormValidator;

use strict;
use MRO::Compat;
use Data::FormValidator;

our $VERSION = '0.094';
$VERSION = eval $VERSION;

sub prepare {
    my $c = shift;
    $c = $c->maybe::next::method(@_);
    $c->{form} = Data::FormValidator->check( $c->request->parameters, {} );
    return $c;
}


sub form {
    my $c = shift;
    if ( $_[0] ) {
        my $form = $_[1] ? {@_} : $_[0];
        $c->{form} =
          Data::FormValidator->check( $c->request->parameters, $form );
    }
    return $c->{form};
}
1;