The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Validator::Var - variable validator with expandable list of checkers.

VERSION

Version 0.03

SYNOPSIS

    use Validator::Var;
    my $var;
    
    ...

    my $num_bitween = Validator::Var->new();
    $foo->checker(Between, 0, 100);
    unless ( $foo->is_valid( $var ) ) {
        warn "variable is not bitween 0 an 100";
    }

    my $number = Validator::Var->new();
    $number->checker(Regexp, '^d+$');
    
    unless ( $bar->is_valid( $var ) ) {
        warn "variable is not a number";
    }
    
    my $ref_validator = Validator::Var->new();
    $ref_validator->checker(Ref, qw(REF Foo Bar));
    unless ( $bar->is_valid( $var ) ) {
        warn "variable is not a number";
    }

 
    ...

METHODS

new( [$at_least_one] )

Creates new variable validator. If at_least_one is provided and it is true validation will be passed if passed through at least one checker.

is_empty

Checks if variable validator has no any checker.

at_least_one( $bool )

checker( $checker[, $checker_args] )

Set (append) new checker.

checkers_not_passed

is_valid( $var [, $do_trace] )

Checks if variable value is valid according to specified checkers. Trace data will be gathered if do_trace is provided and it is true.

Print trace of variable checking. format specifies format string of trace messages. Recognizes the following macro:

%name%

Replaced by checker's name.

%args%

Replaced by checker's arguments.

%desc%

Replaced by checker's description.

%result%

Replaced by 'passed' or 'failed'.

Default format string is "Checker %name%(%args%) - %desc% ... %result%".

AUTHOR

Fedor Semenov, <fedor.v.semenov at gmail.com>

BUGS

Please report any bugs or feature requests to bug-validator-var at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Validator-Var. 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 Validator::Var

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

Copyright 2011 Fedor Semenov.

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.