Valiant::Validator::Presence - Verify that a value is present
package Local::Test::Presence; use Moo; use Valiant::Validations; has name => (is=>'ro'); validates name => ( presence => 1 ); my $object = Local::Test::Presence->new(); $object->validate; warn $object->errors->_dump; $VAR1 = { 'name' => [ 'Name can\'t be blank', ] };
Value must be present (not undefined, not an empty string or a string composed only of whitespace). Uses is_blank as the translation tag and you can set that to override the message.
is_blank
This validator supports the follow shortcut forms:
validates attribute => ( presence => 1, ... );
Which is the same as:
validates attribute => ( presence => +{}, );
Not a lot of saved typing but it seems to read better.
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.