++ed by:

1 non-PAUSE user.

Matthias Bloch
and 4 contributors

NAME

Data::Processor::ValidatorFactory - create validators for use in schemas

SYNOPSIS

 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))
    }
 }

DESCRIPTION

The ValidatorFactory lets you create falidator functions for use in Data::Processor schemas.

METHODS

new

create an instance of the factory

file($operation,$message)

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');

dir()

check if the given directory exists

 $vf->dir();

rx($rx,$message)

apply the regular expression to the value and return $message if it does not match.

 $vf->rx(qr{[A-Z]+},'use uppercase letters')

any(@list)

value must be one of the values of the @list

 $vf->any(qw(ON OFF))

COPYRIGHT

Copyright (c) 2015 by OETIKER+PARTNER AG. All rights reserved.

AUTHOR

Tobias Oetiker <tobi@oetiker.ch>

LICENCE

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.