Valiant::Validator::Exclusion - Value cannot be in a list
package Local::Test::Exclusion; use Moo; use Valiant::Validations; has domain => (is=>'ro'); has country => (is=>'ro'); validates domain => ( exclusion => +{ in => [qw/org co/], }, ); validates country => ( inclusion => +{ in => \&restricted, }, ); sub restricted { my $self = shift; return (qw(usa uk)); } my $object = Local::Test::Exclusion->new( domain => 'org', country => 'usa', ); $object->validate; warn $object->errors->_dump; $VAR1 = { 'country' => [ 'Country is reserved' ], 'domain' => [ 'Domain is reserved' ] };
Value cannot be from a list of reserved values. Value can be given as either an arrayref or a coderef (which recieves the validating object as the first argument, so you can call methods for example).
If value is invalid uses the exclusion translation tag (which you can override as an argument).
exclusion
This validator supports the follow shortcut forms:
validates attribute => ( exclusion => [qw/a b c/], ... );
Which is the same as:
validates attribute => ( exclusion => +{ in => [qw/a b c/], }, );
This also works for the coderef form:
validates attribute => ( exclusion => \&coderef, ... ); validates attribute => ( exclusion => +{ in => \&coderef, }, );
This validator supports all the standard shared parameters: if, unless, message, strict, allow_undef, allow_blank.
if
unless
message
strict
allow_undef
allow_blank
Valiant, Valiant::Validator, Valiant::Validator::Each.
See Valiant
To install Valiant, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Valiant
CPAN shell
perl -MCPAN -e shell install Valiant
For more information on module installation, please visit the detailed CPAN module installation guide.