If a type is parameterizable and has both a "constraint" and a "constraint_generator", then its "deep_explanation" will never be called. As a result validate_explain won't get the "nice" description even when available.
See the example code, attached.
Subject: | no_has_deep.t |
use strict;
use warnings;
use Type::Tiny;
use Test::More;
my $type_with = "Type::Tiny"->new
(
constraint => sub { 0 }, # Reject everything
name => "HasParam",
message => sub { "$_ ain't got a number" },
constraint_generator => sub { sub { 0 } }, # Reject everything
deep_explanation => sub { ["love to contradict"] },
);
my $type_without = "Type::Tiny"->new
(
name => "HasParam",
message => sub { "$_ ain't got a number" },
constraint_generator => sub { sub { 0 } }, # Reject everything
deep_explanation => sub { ["love to contradict"] },
);
my $s = 'a string';
my $param_with = $type_with->parameterize('an ignored parameter');
my $param_without = $type_without->parameterize('an ignored parameter');
my $explain_with=join("\n ",'With a plain constraint:',
@{$param_with->validate_explain($s,'$s')});
my $explain_without=join("\n ",'Without a plain constraint:',
@{$param_without->validate_explain($s,'$s')});
diag "$explain_with\n";
diag "$explain_without\n";
ok $explain_with eq $explain_without;