Data-Tubes
view release on metacpan or search on metacpan
lib/Data/Tubes/Plugin/Validator.pod view on Meta::CPAN
['is-even', 0, "odd\n"], # exception to failure
['in-bound', 0, "too low"] # exception to failure
]
=back
You hopefully get the idea at this point.
It's important to always remember the difference between the following
validators:
sub { ($_[0]{number} % 2 == 0) or die "odd\n" };
sub { die "odd\n" if $_[0]{number} % 2 };
The second validator I<always fails>: it either throws an exception, or
returns a I<false> value. This is not the case with the first one.
Always remember to return a true value from your validators, like this:
sub { die "odd\n" if $_[0]{number} % 2; 1 }
(Yes, this actually happened while writing the tests...)
=head2 B<< validate_admit >>
Alias for L</admit>.
=head2 B<< validate_refuse >>
Alias for L</refuse>.
=head2 B<< validate_refuse_comment >>
Alias for L</refuse_comment>.
=head2 B<< validate_refuse_comment_or_empty >>
Alias for L</refuse_comment_or_empty>.
=head2 B<< validate_refuse_empty >>
Alias for L</refuse_empty>.
=head2 B<< validate_thoroughly >>
Alias for L</thoroughly>.
=head2 B<< validate_with_subs >>
Alias for L</with_subs>.
=head2 B<< with_subs >>
$tube = with_subs(@validators); # OR
$tube = with_subs(@validators, \%args);
This function is DEPRECATED and currently aliased to L</thoroughly>. It
used to do all that L</thoroughly> does, except handling regular
expression validators; now ith supports them too, which is why a name
change was necessary.
=head1 BUGS AND LIMITATIONS
Report bugs either through RT or GitHub (patches welcome).
=head1 AUTHOR
Flavio Poletti <polettix@cpan.org>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2016 by Flavio Poletti <polettix@cpan.org>
This module is free software. You can redistribute it and/or modify it
under the terms of the Artistic License 2.0.
This program is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of
merchantability or fitness for a particular purpose.
=cut
( run in 0.685 second using v1.01-cache-2.11-cpan-39bf76dae61 )