| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package XAS::Service::CheckParameters; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use XAS::Class |
|
6
|
1
|
|
|
|
|
8
|
debug => 0, |
|
7
|
|
|
|
|
|
|
version => $VERSION, |
|
8
|
|
|
|
|
|
|
base => 'XAS::Base', |
|
9
|
|
|
|
|
|
|
utils => ':validation dotid', |
|
10
|
|
|
|
|
|
|
codec => 'JSON', |
|
11
|
|
|
|
|
|
|
constants => 'HASHREF', |
|
12
|
|
|
|
|
|
|
mixins => 'check_parameters', |
|
13
|
1
|
|
|
1
|
|
582
|
; |
|
|
1
|
|
|
|
|
1
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
#use Data::Dumper; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- |
|
18
|
|
|
|
|
|
|
# Public Methods |
|
19
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub check_parameters { |
|
22
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
23
|
0
|
|
|
|
|
|
my ($params, $type) = validate_params(\@_, [ |
|
24
|
|
|
|
|
|
|
{ type => HASHREF }, |
|
25
|
|
|
|
|
|
|
1, |
|
26
|
|
|
|
|
|
|
]); |
|
27
|
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
my @errors; |
|
29
|
0
|
|
|
|
|
|
my $results = $self->profile->check($params, $type); |
|
30
|
0
|
|
|
|
|
|
my $valids = $results->valid(); |
|
31
|
|
|
|
|
|
|
|
|
32
|
0
|
0
|
|
|
|
|
if ($results->has_missing) { |
|
33
|
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
for my $f ($results->missing) { |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $error = { |
|
37
|
|
|
|
|
|
|
id => $f, |
|
38
|
0
|
|
0
|
|
|
|
msg => $results->msgs->{'missing'} || 'is missing', |
|
39
|
|
|
|
|
|
|
}; |
|
40
|
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
push(@errors, $error); |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
0
|
0
|
|
|
|
|
if ($results->has_invalid) { |
|
48
|
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
for my $f ($results->invalid) { |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my $error = { |
|
52
|
|
|
|
|
|
|
id => $f, |
|
53
|
0
|
|
0
|
|
|
|
msg => $results->msgs->{$f} || 'is invalid', |
|
54
|
|
|
|
|
|
|
}; |
|
55
|
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
push(@errors, $error); |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
0
|
0
|
|
|
|
|
if (scalar(@errors) > 0) { |
|
63
|
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
$self->throw_msg( |
|
65
|
|
|
|
|
|
|
dotid($self->class) . '.check_parameters.' . $type, |
|
66
|
|
|
|
|
|
|
'errors', |
|
67
|
|
|
|
|
|
|
encode(@errors) |
|
68
|
|
|
|
|
|
|
); |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
return $valids; |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
__END__ |