Validation::Class::Simple - Simple Inline Validation Class
version 5.51
Validation::Class::Simple is a drop-in validation class derived from the Validation::Class framework. This package is intended to be used in situations where a full-fledged validation class is not warranted, e.g. (scripts, etc).
Simply define your data validation profile and execute, much in the same way you would use most other data validation libraries available.
Should you find yourself wanting to switch to a full-fledged validation class using Validation::Class, you could do so very easily as the validation field specification is exactly the same.
use Validation::Class::Simple; my $fields = { 'login' => { label => 'User Login', error => 'Login invalid.', required => 1, validation => sub { my ($self, $this_field, $all_params) = @_; return $this_field->{value} eq 'admin' ? 1 : 0; } }, 'password' => { label => 'User Password', error => 'Password invalid.', required => 1, validation => sub { my ($self, $this_field, $all_params) = @_; return $this_field->{value} eq 'pass' ? 1 : 0; } } }; my $input = Validation::Class::Simple->new( fields => $fields, params => $params ); unless ( $input->validate ) { return $input->errors_to_string; }
Al Newkirk <awncorp@cpan.org>
This software is copyright (c) 2011 by awncorp.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Validation::Class, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Validation::Class
CPAN shell
perl -MCPAN -e shell install Validation::Class
For more information on module installation, please visit the detailed CPAN module installation guide.