NAME
Data::Validate::WithYAML - Validation framework that can be configured with YAML files
VERSION
version 0.09
SYNOPSIS
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
METHODS
new
my $foo = Data::Validate::WithYAML->new( 'filename' );
creates a new object.
set_optional
This method makes a field optional if it was required
set_required
This method makes a field required if it was optional
validate
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 );
fieldnames
errstr
message
returns the message if specified in YAML
$obj->message( 'fieldname' );
check_list
$obj->check_list('fieldname',['value','value2']);
Checks if the values match the validation criteria. Returns an arrayref with checkresults:
[
1,
0,
]
check
$obj->check('fieldname','value');
checks if a value is valid. returns 1 if the value is valid, otherwise it returns 0.
AUTHOR
Renee Baecker, <module at renee-baecker.de>
BUGS
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.
SUPPORT
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
CPAN Ratings
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Data::Validate::WithYAML
Search CPAN
ACKNOWLEDGEMENTS
COPYRIGHT & LICENSE
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.
AUTHOR
Renee Baecker <module@renee-baecker.de>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2012 by Renee Baecker.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)