line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Params::Validate::Checks::Integer; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
2
|
|
|
2
|
|
406256
|
$Params::Validate::Checks::Integer::VERSION = '0.01'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
# ABSTRACT: Params::Validate checks for functions taking integer arguments |
6
|
2
|
|
|
2
|
|
21
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
58
|
|
7
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
56
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
11
|
use Params::Validate::Checks 0.01; |
|
2
|
|
|
|
|
58
|
|
|
2
|
|
|
|
|
155
|
|
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
1712
|
use Scalar::Util::Numeric 0.22 qw(isint); |
|
2
|
|
|
|
|
1517
|
|
|
2
|
|
|
|
|
252
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Params::Validate::Checks::register( |
16
|
|
|
|
|
|
|
'integer' => sub {return isint($_[0]) } |
17
|
|
|
|
|
|
|
, 'non-neg-int' => sub {return isint($_[0]) == 1} ); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
1; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
__END__ |
24
|
|
|
|
|
|
|
=pod |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 NAME |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Params::Validate::Checks::Integer - Params::Validate checks for functions taking integer arguments |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 VERSION |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
version 0.01 |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 SYNOPSIS |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
use Params::Validate::Checks qw<validate as>; |
37
|
|
|
|
|
|
|
use Params::Validate::Checks::Integer; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub league_table_row |
40
|
|
|
|
|
|
|
{ |
41
|
|
|
|
|
|
|
my %arg = validate @_, |
42
|
|
|
|
|
|
|
{ |
43
|
|
|
|
|
|
|
position => { as 'pos_int' }, #From P::V::Checks |
44
|
|
|
|
|
|
|
games_played => { as 'non-neg-int' }, |
45
|
|
|
|
|
|
|
points => { as 'integer' }, #Allow for points deducted! |
46
|
|
|
|
|
|
|
goal_difference |
47
|
|
|
|
|
|
|
=> { as 'integer' }, |
48
|
|
|
|
|
|
|
}; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# Do something with this league table position. |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 DESCRIPTION |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
This is a library of named checks for use with L<Params::Validate> to validate |
56
|
|
|
|
|
|
|
all integers and those that should be non-negative. See L<Params::Validate::Checks> |
57
|
|
|
|
|
|
|
for in-built validation of positive (non-zero) integers. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 Checks |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
The following named checks are supplied by this module. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=over |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=item C<integer> |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
an integer value, which can be positive, negative or zero. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=item C<non-neg-int> |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
an integer value, which can be positive or zero. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=back |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 NAME |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Params::Validate::Checks::Integer - Params::Validate checks for functions |
78
|
|
|
|
|
|
|
taking integer arguments. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 SEE ALSO |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=over 2 |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=item * |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
L<Params::Validate::Checks>, the framework this is using |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item * |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
L<Scalar::Util::Numeric>, provider of the isint() check. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=back |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 CREDITS |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Smylers <smylers@cpan.org> for Params::Validate::Checks. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
chocolateboy <chocolate@cpan.org> for Scalar::Util::Numeric |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 AUTHOR |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Stephen Cardie <stephenca@cpan.org> |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
This software is Copyright (c) 2011 by Stephen Cardie. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
This is free software, licensed under: |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=cut |
113
|
|
|
|
|
|
|
|