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