add manifest skip file
[gitmo/MooseX-Types-Common.git] / lib / MooseX / Types / Common / Numeric.pm
CommitLineData
ac73ab52 1package MooseX::Types::Common::Numeric;
2
3use strict;
4use warnings;
5
6our $VERSION = '0.001000';
7
8use MooseX::Types -declare => [
9 qw(PositiveNum PositiveInt NegativeNum NegativeInt SingleDigit)
10];
11
12use MooseX::Types::Moose qw/Num Int/;
13
14subtype PositiveNum,
15 as Num,
16 where { $_ >= 0 },
17 message { "Must be a positive number" };
18
19subtype PositiveInt,
20 as Int,
21 where { $_ >= 0 },
22 message { "Must be a positive integer" };
23
24subtype NegativeNum,
25 as Num,
26 where { $_ <= 0 },
27 message { "Must be a negative number" };
28
29subtype NegativeInt,
30 as Int,
31 where { $_ <= 0 },
32 message { "Must be a negative integer" };
33
34subtype SingleDigit,
35 as PositiveInt,
36 where { $_ <= 9 },
37 message { "Must be a single digit" };
38
39
401;
41
42__END__;
43
44
45=head1 NAME
46
47MooseX::Types::Common::Numeric
48
49=head1 SYNOPSIS
50
51 use MooseX::Types::Common::Numeric qw/PositiveInt/;
52 has count => (is => 'rw', isa => PositiveInt);
53
54 ...
55 #this will fail
56 $object->count(-33);
57
58=head1 DESCRIPTION
59
60A set of commonly-used numeric type constraints that do not ship with Moose by
61default.
62
63=over
64
65=item * PositiveNum
66
67=item * PositiveInt
68
69=item * NegativeNum
70
71=item * Int
72
73=item * SingleDigit
74
75=back
76
77=head1 SEE ALSO
78
79=over
80
81=item * L<MooseX::Types::Common::String>
82
83=back
84
85=head1 AUTHORS
86
87Please see:: L<MooseX::Types::Common>
88
89=cut