Data::Validate::WithYAML - Validation framework that can be configured with YAML files
version 0.09
Perhaps a little code snippet.
use Data::Validate::WithYAML; my $foo = Data::Validate::WithYAML->new( 'test.yml' ); my %map = ( name => 'Test Person', password => 'xasdfjakslr453$', plz => 64569, word => 'Herr', age => 55, ); for my $field ( keys %map ){ print "ok: ",$map{$field},"\n" if $foo->check( $field, $map{$field} ); }
data.yml
--- step1: name: type: required length: 8,122 password: type: required length: 10, plz: regex: ^\d{4,5}$ type: optional word: enum: - Herr - Frau - Firma age: type: required min: 18 max: 65
my $foo = Data::Validate::WithYAML->new( 'filename' );
creates a new object.
This method makes a field optional if it was required
This method makes a field required if it was optional
This subroutine validates one form. You have to pass the form name (key in the config file), a hash with fieldnames and its values
my %fields = ( username => $cgi->param('user'), passwort => $password, ); $foo->validate( 'step1', %fields );
returns the message if specified in YAML
$obj->message( 'fieldname' );
$obj->check_list('fieldname',['value','value2']);
Checks if the values match the validation criteria. Returns an arrayref with checkresults:
[ 1, 0, ]
$obj->check('fieldname','value');
checks if a value is valid. returns 1 if the value is valid, otherwise it returns 0.
Renee Baecker, <module at renee-baecker.de>
<module at renee-baecker.de>
Please report any bugs or feature requests to bug-data-validate-withyaml at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Data::Validate::WithYAML. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-data-validate-withyaml at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Data::Validate::WithYAML
You can also look for information at:
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Data::Validate::WithYAML
CPAN Ratings
http://cpanratings.perl.org/d/Data::Validate::WithYAML
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Data::Validate::WithYAML
Search CPAN
http://search.cpan.org/dist/Data::Validate::WithYAML
Copyright 2007 - 2012 Renee Baecker, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the terms of Artistic License 2.0.
Renee Baecker <module@renee-baecker.de>
This software is Copyright (c) 2012 by Renee Baecker.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
To install Data::Validate::WithYAML, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Validate::WithYAML
CPAN shell
perl -MCPAN -e shell install Data::Validate::WithYAML
For more information on module installation, please visit the detailed CPAN module installation guide.