tiny POD update and cosmetic dist stuff
[gitmo/MooseX-Types-Common.git] / lib / MooseX / Types / Common / Numeric.pm
CommitLineData
ac73ab52 1package MooseX::Types::Common::Numeric;
2
3use strict;
4use warnings;
5
6820e939 6our $VERSION = '0.001001';
ac73ab52 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
ac73ab52 391;
40
41__END__;
42
ac73ab52 43=head1 NAME
44
6820e939 45MooseX::Types::Common::Numeric - Commonly used numeric types
ac73ab52 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
58A set of commonly-used numeric type constraints that do not ship with Moose by
59default.
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
85Please see:: L<MooseX::Types::Common>
86
87=cut