Data::Processor::ValidatorFactory - create validators for use in schemas
use Data::Processor::ValidatorFactory; my $vf = Data::Processor::ValidatorFactory->new; my $SCHEMA = { log => { validator => $vf->file('>','writing'), }, name => { validator => $vf->rx(qr{[A-Z]+},'expected name made up from capital letters') }, mode => { validator => $vf->any(qw(UP DOWN)) } }
The ValidatorFactory lets you create falidator functions for use in Data::Processor schemas.
create an instance of the factory
use the three parameter open to access the 'value' of if this does not work return $message followed by the filename and the errormessage
$vf->file('<','reading'); $vf->file('>>','appending to');
check if the given directory exists
$vf->dir();
apply the regular expression to the value and return $message if it does not match.
$vf->rx(qr{[A-Z]+},'use uppercase letters')
value must be one of the values of the @list
$vf->any(qw(ON OFF))
Copyright (c) 2015 by OETIKER+PARTNER AG. All rights reserved.
Tobias Oetiker <tobi@oetiker.ch>
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
To install Data::Processor, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Processor
CPAN shell
perl -MCPAN -e shell install Data::Processor
For more information on module installation, please visit the detailed CPAN module installation guide.