Skip to content

dim0xff/p5-Form-Data-Processor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NAME

Form::Data::Processor - Yet another form data validator

SYNOPSIS

package MyForm::Field::Address;

use Form::Data::Processor::Moose;
extends 'Form::Data::Processor::Field::Compound';

has_field zip     => ( type => 'Text', required => 1 );
has_field addr1   => ( type => 'Text', required => 1 );
has_field addr2   => ( type => 'Text' );
has_field state   => ( type => 'Text', required => 1 );
has_field country => ( type => 'Text', required => 1 );

...

package MyForm;

use Form::Data::Processor::Moose;
extends 'Form::Data::Processor::Form';

has_field 'addresses'         => ( type => 'Repeatable' );
has_field 'addresses.address' => ( type => '+MyForm::Field::Address' );
has_field 'addresses.type' => (
    type           => 'List',
    required       => 1,
    options        => [ 'BILLING', 'SHIPPING' ],
    multiple       => 0,
);


...

# later in your controller
my $form = MyForm->new;
die 'Not valid' $unless form->process( $ctx->params );

DESCRIPTION

Yet another form data validator, which is inspired by HTML::FormHandler.

It has similar syntax and similar features, but it is NOT a form generator. Anyway you can extend it as you wish.

Form::Data::Processor vs HTML::FormHandler

I don't like Repeatable field in HFH - it is too slow (as the whole HFH is). But I like its syntax. So FDP should be a little bit faster than HFH.

Please look at benchmarks (benchmarks folder).

START HERE

Form::Data::Processor::Form
Form::Data::Processor::Field

SEE ALSO

HTML::FormHandler - HTML form validator and generator.

AUTHOR

Dmitry "dim0xff" Latin <dim0xff@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2015 by Dmitry Latin.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

About

Yet another form data validator

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages