line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Valiemon::Attributes::OneOf; |
2
|
2
|
|
|
2
|
|
1298
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
61
|
|
3
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
49
|
|
4
|
2
|
|
|
2
|
|
11
|
use utf8; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
10
|
|
5
|
2
|
|
|
2
|
|
501
|
use parent qw(Valiemon::Attributes); |
|
2
|
|
|
|
|
299
|
|
|
2
|
|
|
|
|
10
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
125
|
use Carp qw(croak); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
99
|
|
8
|
2
|
|
|
2
|
|
527
|
use List::MoreUtils qw(one); |
|
2
|
|
|
|
|
12023
|
|
|
2
|
|
|
|
|
13
|
|
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
1687
|
use Valiemon::Context; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
397
|
|
11
|
|
|
|
|
|
|
|
12
|
13
|
|
|
13
|
0
|
42
|
sub attr_name { 'oneOf' } |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub is_valid { |
15
|
15
|
|
|
15
|
0
|
37
|
my ($class, $context, $schema, $data) = @_; |
16
|
|
|
|
|
|
|
|
17
|
15
|
|
|
|
|
30
|
my $oneOf = $schema->{oneOf}; |
18
|
15
|
100
|
66
|
|
|
84
|
if (ref $oneOf ne 'ARRAY' || scalar @$oneOf < 1) { |
19
|
2
|
|
|
|
|
7
|
croak sprintf '`oneOf` must be an array and have at least one element at %s', $context->position |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
$context->in_attr($class, sub { |
23
|
|
|
|
|
|
|
one { |
24
|
24
|
|
|
|
|
86
|
my $clone_context = Valiemon::Context->clone_from($context); |
25
|
24
|
|
|
|
|
321
|
$clone_context->sub_validator($_)->validate($data, $clone_context); |
26
|
13
|
|
|
13
|
|
65
|
} @$oneOf; |
27
|
13
|
|
|
|
|
71
|
}); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
1; |