line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Valiemon::Attributes::OneOf; |
2
|
2
|
|
|
2
|
|
850
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
50
|
|
3
|
2
|
|
|
2
|
|
5
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
37
|
|
4
|
2
|
|
|
2
|
|
6
|
use utf8; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
8
|
|
5
|
2
|
|
|
2
|
|
370
|
use parent qw(Valiemon::Attributes); |
|
2
|
|
|
|
|
222
|
|
|
2
|
|
|
|
|
7
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
89
|
use Carp qw(croak); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
78
|
|
8
|
2
|
|
|
2
|
|
418
|
use List::MoreUtils qw(one); |
|
2
|
|
|
|
|
7247
|
|
|
2
|
|
|
|
|
10
|
|
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
688
|
use Valiemon::Context; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
283
|
|
11
|
|
|
|
|
|
|
|
12
|
13
|
|
|
13
|
0
|
23
|
sub attr_name { 'oneOf' } |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub is_valid { |
15
|
15
|
|
|
15
|
0
|
17
|
my ($class, $context, $schema, $data) = @_; |
16
|
|
|
|
|
|
|
|
17
|
15
|
|
|
|
|
16
|
my $oneOf = $schema->{oneOf}; |
18
|
15
|
100
|
66
|
|
|
63
|
if (ref $oneOf ne 'ARRAY' || scalar @$oneOf < 1) { |
19
|
2
|
|
|
|
|
5
|
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
|
|
|
|
|
62
|
my $clone_context = Valiemon::Context->clone_from($context); |
25
|
24
|
|
|
|
|
235
|
$clone_context->sub_validator($_)->validate($data, $clone_context); |
26
|
13
|
|
|
13
|
|
56
|
} @$oneOf; |
27
|
13
|
|
|
|
|
47
|
}); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
1; |