Subject: | message for nested subtypes |
Let assume following hierarchy:
subtype 'Int',
as 'Real',
where { int($_) == $_ },
message {"$_ is not integer"};
subtype 'PositiveInt',
as 'Int',
where { $_ >= 0 },
message {"$_ is not positive"};
in case of positive non-integer 1.5 message still will be "1.5 is not
positive". Example of more complex hierarchy is
Perl::Dist::WiX::Types, you can see source at
http://cpansearch.perl.org/src/CSJEWELL/Perl-Dist-WiX-1.500002/lib/Perl/Dist/WiX/Types.pm
There are two possible solutions:
1. Document that message should contain all restrictions. This means
that message may be long (7 conditions in case of
Perl::Dist::WiX::Types) and it may not be clear which restriction
failed.
2. Make Moose output message from restriction that failed ("1.5 is not
integer").
--
Alexandr Ciornii, http://chorny.net