Valiant::Validator::Scalar - Validate that a value is a scalar (like a string or number)
package Local::Test::Scalar; use Moo; use Valiant::Validations; has name => (is=>'ro'); validates name => ( scalar => 1 ); ok my $object = Local::Test::Scalar->new(name=>[111,'John']); ok $object->validate->invalid; is_deeply +{ $object->errors->to_hash(full_messages=>1) }, { 'name' => [ 'Name must be a string or number', ] };
Validates that the value in question is a scalar.
This validator supports the follow shortcut forms:
validates attribute => ( scalar => 1, ... );
Which is the same as:
validates attribute => ( scalar => { }, );
This validator supports all the standard shared parameters: if, unless, message, strict, allow_undef, allow_blank.
if
unless
message
strict
allow_undef
allow_blank
John Napiorkowski email:jjnapiork@cpan.org
Valiant, Valiant::Validator, Valiant::Validator::Each.
Copyright 2020, John Napiorkowski email:jjnapiork@cpan.org
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
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.