Skip Menu |

This queue is for tickets about the Type-Tiny CPAN distribution.

Report information
The Basics
Id: 128046
Status: rejected
Priority: 0/
Queue: Type-Tiny

People
Owner: Nobody in particular
Requestors: djerius [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 1.004002
Fixed in: (no value)



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;
This is by design, but it may need better documentation. Since Types::Standard 1.003_003, the Bool type has had a coercion by default, so "not a boolean" will get coerced to !!1. If you don't want to coerce values, you can use Bool->no_coercions to get a copy of Bool without any coercions.