Hi,
I'm having a problem creating a custom type library. I have followed
the example on cpan, yet when I use my type it always gives me this error
'Attribute (positiveint) does not pass the type constraint because:
Validation failed for 'PositiveInt' with value 12 (not isa PositiveInt)
at test.pl line 7'.
It doesn't matter what value I use its always the same, just a different
value. Any pointers as to where I am going wrong will be appreciated.
I have pasted my code below
test.pl
#!/usr/bin/perl
use strict;
use TypesTest;
my $typetest = TypesTest->new;
$typetest->positiveint(12);
print $typetest->positiveint;
exit;
TypesTest.pm
use MooseX::Declare;
class TypesTest
{
use TypeLibrary ':all';
has 'positiveint', isa => 'PositiveInt', is => 'rw';
}
TypeLibrary.pm
package TypeLibrary;
# predeclare our own types
use MooseX::Types
-declare => [qw(
PositiveInt
)];
# import builtin types
use MooseX::Types::Moose ':all';
# type definitions
subtype PositiveInt,
as Int,
where { $_ > 0 },
message { "Int is not greater than 0" };
1;
--
Chris Williams
Web Developer, Radian IT Ltd
http://www.radianit.com
T: 01482 221 882
M: 07817 245 805