Reaction::Types::Core - Reaction::Types::Core documentation


Reaction documentation Contained in the Reaction distribution.

Index


Code Index:

NAME

Top

Reaction::Types::Core

SYNOPSIS

Top

DESCRIPTION

Top

Reaction uses the Moose attributes as a base and adds a few of it's own.

* SimpleStr

A Str with no new-line characters.

* NonEmptySimpleStr

Does what it says on the tin.

* Password
* StrongPassword
* NonEmptyStr
* PositiveNum
* PositiveInt
* SingleDigit

SEE ALSO

Top

* Moose::Util::TypeConstraints
* Reaction::Types::DBIC
* Reaction::Types::DateTime
* Reaction::Types::Email
* Reaction::Types::File

AUTHORS

Top

See Reaction::Class for authors.

LICENSE

Top

See Reaction::Class for the license.


Reaction documentation Contained in the Reaction distribution.

package Reaction::Types::Core;

use MooseX::Types
    -declare => [qw/SimpleStr NonEmptySimpleStr Password StrongPassword
                    NonEmptyStr PositiveNum PositiveInt SingleDigit URI/];

use MooseX::Types::Moose qw/Str Num Int Object/;

subtype SimpleStr,
  as Str,
  where { (length($_) <= 255) && ($_ !~ m/\n/) },
  message { "Must be a single line of no more than 255 chars" };

subtype NonEmptySimpleStr,
  as SimpleStr,
  where { length($_) > 0 },
  message { "Must be a non-empty single line of no more than 255 chars" };

# XXX duplicating constraint msges since moose only uses last message

subtype Password,
  as NonEmptySimpleStr,
  where { length($_) > 3 },
  message { "Must be between 4 and 255 chars" };

subtype StrongPassword,
  as Password,
  where { (length($_) > 7) && (m/[^a-zA-Z]/) },
  message {
       "Must be between 8 and 255 chars, and contain a non-alpha char" };

subtype NonEmptyStr,
  as Str,
  where { length($_) > 0 },
  message { "Must not be empty" };

subtype PositiveNum,
  as Num,
  where { $_ >= 0 },
  message { "Must be a positive number" };

subtype PositiveInt,
  as Int,
  where { $_ >= 0 },
  message { "Must be a positive integer" };

subtype SingleDigit,
  as PositiveInt,
  where { $_ <= 9 },
  message { "Must be a single digit" };

#message will require moose 0.39
class_type 'URI';
#class_type 'URI', message { 'Must be an URI object'};
coerce 'URI', from Str, via { URI->new($_) };

1;