NAME

Project::Euler::Lib::Types - Type definitions for Project::Euler

VERSION

version 0.20

SYNOPSIS

use Project::Euler::Lib::Types  qw/ ProblemLink  PosInt /;

DESCRIPTION

(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.

SUBTYPES

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.

Definition

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
};

ProblemName

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

Definition

as Str,
message { sprintf(q{'%s' must be a string between 10 and 80 characters long}, $_ // '#UNDEFINED#') },
where {
    length $_ > 10  and  length $_ < 80;
};

PosInt

An integer greater than 0.

Definition

as Int,
message { sprintf(q{'%s' is not greater than 0}, $_ // '#UNDEFINED#') },
where {
    $_ > 0
}

PosIntArray

An array of PosInts.

NegInt

An integer less than 0.

Definition

as Int,
message { sprintf(q{'%s' is not less than 0}, $_ // '#UNDEFINED#') },
where {
    $_ < 0
}

NegIntArray

An array of NegInts.

MyDateTime

A DateTime:: object coerced using DateTime::Format::DateParse

Definition

class_type MyDateTime, { class => 'DateTime' };
coerce MyDateTime,
    from Str,
    via {
        DateTime::Format::DateParse->parse_datetime( $_ );
    };

ACKNOWLEDGEMENTS

AUTHOR

Adam Lesperance <lespea@gmail.com>

COPYRIGHT AND LICENSE

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.