line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Validator::Role::Ordered; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Data::Validator::Role::Ordered - Provide results as a list in the order |
6
|
|
|
|
|
|
|
specified. |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 SYNOPSIS |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use Data::Validator; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub test { |
13
|
|
|
|
|
|
|
state $arguments = Data::Validator->new( |
14
|
|
|
|
|
|
|
foo => "Str", |
15
|
|
|
|
|
|
|
bar => "Num", |
16
|
|
|
|
|
|
|
)->with(qw( Method Sequenced Ordered )); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my ($self, $foo, $bar) = $arguments->validate(@_); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 DESCRIPTION |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
The Ordered Role adds to Data::Validator the ability for the `validate` method |
24
|
|
|
|
|
|
|
to return an ordered list, with values matching the specification provided by |
25
|
|
|
|
|
|
|
Data::Validator. |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=cut |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
1
|
|
10621
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
52
|
|
30
|
1
|
|
|
1
|
|
7
|
use warnings FATAL => "all"; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
464
|
|
31
|
1
|
|
|
1
|
|
18
|
use Mouse::Role; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
with qw( Data::Validator::Role::Sequenced ); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 MODIFIERS |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=over 4 |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=item validate |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Return a list, in order, of arguments rather than the result. |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=cut |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
around validate => sub { |
46
|
|
|
|
|
|
|
my ($next, $self, @args) = @_; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my $args = $self->$next(@args); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
return map $args->{$_->{name}}, @{ $self->rules }; |
51
|
|
|
|
|
|
|
}; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=back |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 CONSIDERATIONS |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Although it should be of nominal impact to performance, due to the constraints |
58
|
|
|
|
|
|
|
of Data::Validator this first maps all provided parameters to a hash, validates |
59
|
|
|
|
|
|
|
them as a hash, and then maps the has back to a list. A more efficient method |
60
|
|
|
|
|
|
|
would clearly to be use just a list from top to bottom. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 BUGS |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
If you find any, feel free to submit them. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
https://github.com/ssmccoy/Data-Validator-Role-Ordered |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 LICENSE |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Copyright © 2012, Say Media INC. |
71
|
|
|
|
|
|
|
Released under the Artistic License, 2.0 |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |