Project::Euler::Lib::Types - Type definitions for Project::Euler
version 0.20
use Project::Euler::Lib::Types qw/ ProblemLink PosInt /;
(Most) all of the types that our modules use are defined here so that they can be reused and tested. This also helps prevent all of the namespace pollution from the global declarations.
Create the subtypes that we will use to validate the arguments defined by the extending classes.
A URL pointing to a problem definition on http://projecteuler.net.
as Str, message { sprintf(q{'%s' is not a valid link}, $_ // '#UNDEFINED#') }, where { $_ =~ m{ \A \Qhttp://projecteuler.net/index.php?section=problems&id=\E \d+ \z }xms };
In an effort to limit text runoff, the problem name is limited to 80 characters. Similarly, the length must also be greater than 10 to ensure it is something useful. Also, only characters, numbers, spaces, and some punctuation (!@#$%^&*(){}[]<>,.\\/?;:'") are allowed
as Str, message { sprintf(q{'%s' must be a string between 10 and 80 characters long}, $_ // '#UNDEFINED#') }, where { length $_ > 10 and length $_ < 80; };
An integer greater than 0.
as Int, message { sprintf(q{'%s' is not greater than 0}, $_ // '#UNDEFINED#') }, where { $_ > 0 }
An array of PosInts.
An integer less than 0.
as Int, message { sprintf(q{'%s' is not less than 0}, $_ // '#UNDEFINED#') }, where { $_ < 0 }
An array of NegInts.
A DateTime:: object coerced using DateTime::Format::DateParse
class_type MyDateTime, { class => 'DateTime' }; coerce MyDateTime, from Str, via { DateTime::Format::DateParse->parse_datetime( $_ ); };
MooseX::Types
Adam Lesperance <lespea@gmail.com>
This software is copyright (c) 2010 by Adam Lesperance.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Project::Euler, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Project::Euler
CPAN shell
perl -MCPAN -e shell install Project::Euler
For more information on module installation, please visit the detailed CPAN module installation guide.