Data::Verifier - Profile based data verification with Moose type constraints.
Data::Verifier allows you verify data (such as web forms, which was the original idea) by leveraging the power of Moose's type constraint system.
use Data::Verifier; my $dv = Data::Verifier->new( filters => [ qw(trim) ] profile => { name => { required => 1, type => 'Str', filters => [ qw(collapse) ] } age => { type => 'Int'; }, sign => { required => 1, type => 'Str' } } ); my $results = $dv->verify({ name => 'Cory', age => 'foobar' }); $results->success; # no $results->is_invalid('name'); # no $results->is_invalid('age'); # yes $results->is_missing('name'); # no $results->is_missing('sign'); # yes
Data::Verifier firstly intends to leverage Moose's type constraint system, which is significantly more powerful than anything I could create for the purposes of this module. Secondly it aims to keep a fairly simple interface by leveraging the aforementioned type system to keep options to a minumum.
This module is under very active development and, while the current API will likely not be changed, features will be added rapidly.
An optional arrayref of filter names through which all values will be passed.
The profile is a hashref. Each value you'd like to verify is a key. The values specify all the options to use with the field. The available options are:
An optional list of filters through which this specific value will be run. See the documentation for Data::Verifier::Filters to learn more. This value may be either a string or an arrayref of strings.
Determines if this field is required for verification.
The name of the Moose type constraint to use with verifying this field's value.
Cory G Watson, <gphat at cpan.org>
<gphat at cpan.org>
Copyright 2009 Cold Hard Code, LLC
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install Data::Verifier, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Verifier
CPAN shell
perl -MCPAN -e shell install Data::Verifier
For more information on module installation, please visit the detailed CPAN module installation guide.