Write validation helpers 

package DemoApp::Validator;

use strict;
use warnings;
use autodie;

use Data::FormValidator;
use Data::FormValidator::Constraints qw(:closures);

my $dfv = Data::FormValidator->new({

    '/user/add' => {
        required  => [qw( username full_name email password password_confirm )],
        filters   => ['trim'],
        constraint_methods => {
            username  => qr{^([\w.-]+)$},
            full_name => qr{^([\w\s'.()-]+)$},
            email     => email(),
            password  => {
                params            => [qw( password password_confirm )],
                constraint_method => sub {
                    return $_[1] eq $_[2];
                }
            },
            password_confirm  => {
                params            => [qw( password password_confirm )],
                constraint_method => sub {
                    return $_[1] eq $_[2];
                }
            },
        },
    },

    '/user/edit' => {
        required  => [qw( username full_name email )],
        # ...
    },

    # ...

});

sub check {
    my($params, $name) = @_;

    return $dfv->check($params, $name)
}


1;