Subject: | Bool type not properly validated via Type::Params::validate |
Howdy!
I expect the following code to result in an exception, but it doesn't.
use Types::Standard -types;
use Type::Params qw[ validate ];
validate( [ 'not a boolean' ], Bool );
This works as expected:
say Bool->validate( 'not a boolean' );
which results in
'Value "not a boolean" did not pass type constraint "Bool"'
Subject: | types.pl |
#! perl
use Test2::V0;
use Types::Standard -types;
use Type::Params qw[ validate ];
my $bool = 'not true';
# this fails as expected
like(
Bool->validate( $bool ),
qr/did not pass type constraint.*Bool/,
"Bool->validate returns error"
);
like(
dies {
validate( [$bool], Bool )
},
qr/did not pass type constraint.*Bool/,
"Type::Params::validate dies with error"
);
done_testing;