Data/Sah/Type/HasElems.pm

filter: Statementstmt 74.0% 40 / 54 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 10 / 20 Podpod n/a totaltotal 67.5% 50 / 74 CC 1 SCAR 4.1
CC
1
Cov
74%
__ANON__
2.0
__ANON__
2.0
__ANON__
2.0
CRAP 1.5
« Data/Sah/Compiler/perl/TH/int.pm ↑ Summary Data/Sah/Type/hash.pm »
1 package Data::Sah::Type::HasElems;
2  
3 28 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 28 ▶use Data::Sah::Util::Role 'has_clause';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 28 ▶use Role::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 28 requires 'superclause_has_elems';
9  
10 has_clause 'max_len',
11 v => 2,
12 prio => 51,
13 tags => ['constraint'],
14 schema => ['int', {min=>0}],
15 allow_expr => 1,
16 102 ▶ code => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
17 102 my ($self, $cd) = @_;
18 102 $self->superclause_has_elems('max_len', $cd);
19 28 };
20  
21 has_clause 'min_len',
22 v => 2,
23 tags => ['constraint'],
24 schema => ['int', {min=>0}],
25 allow_expr => 1,
26 196 ▶ code => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
27 196 my ($self, $cd) = @_;
28 196 $self->superclause_has_elems('min_len', $cd);
29 28 };
30  
31 has_clause 'len_between',
32 v => 2,
33 tags => ['constraint'],
34 schema => ['array' => {req=>1, len=>2, elems => [
35 [int => {req=>1}],
36 [int => {req=>1}],
37 ]}],
38 allow_expr => 1,
39 60 ▶ code => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
40 60 my ($self, $cd) = @_;
41 60 $self->superclause_has_elems('len_between', $cd);
42 28 };
43  
44 has_clause 'len',
45 v => 2,
46 tags => ['constraint'],
47 schema => ['int', {min=>0}],
48 allow_expr => 1,
49 192 ▶ code => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
50 192 my ($self, $cd) = @_;
51 192 $self->superclause_has_elems('len', $cd);
52 28 };
53  
54 has_clause 'has',
55 v => 2,
56 tags => ['constraint'],
57 schema => ['_same_elem', {req=>1}],
58 inspect_elem => 1,
59 prio => 55, # we should wait for clauses like e.g. 'each_elem' to coerce elements
60 allow_expr => 1,
61 140 ▶ code => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
62 140 my ($self, $cd) = @_;
63 140 $self->superclause_has_elems('has', $cd);
64 28 };
65  
66 has_clause 'each_index',
67 v => 2,
68 tags => ['constraint'],
69 schema => ['sah::schema', {req=>1}],
70 0 ▶ subschema => sub { $_[0] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
71 allow_expr => 0,
72 36 ▶ code => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
73 36 my ($self, $cd) = @_;
74 36 $self->superclause_has_elems('each_index', $cd);
75 28 };
76  
77 has_clause 'each_elem',
78 v => 2,
79 tags => ['constraint'],
80 schema => ['sah::schema', {req=>1}],
81 inspect_elem => 1,
82 0 ▶ subschema => sub { $_[0] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
83 allow_expr => 0,
84 67 ▶ code => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
85 67 my ($self, $cd) = @_;
86 67 $self->superclause_has_elems('each_elem', $cd);
87 28 };
88  
89 has_clause 'check_each_index',
90 v => 2,
91 tags => ['constraint'],
92 schema => ['sah::schema', {req=>1}],
93 0 ▶ subschema => sub { $_[0] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
94 allow_expr => 0,
95 0 ▶ code => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
96 0 my ($self, $cd) = @_;
97 0 $self->superclause_has_elems('check_each_index', $cd);
98 28 };
99  
100 has_clause 'check_each_elem',
101 v => 2,
102 tags => ['constraint'],
103 schema => ['sah::schema', {req=>1}],
104 inspect_elem => 1,
105 0 ▶ subschema => sub { $_[0] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
106 allow_expr => 0,
107 0 ▶ code => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
108 0 my ($self, $cd) = @_;
109 0 $self->superclause_has_elems('check_each_elem', $cd);
110 28 };
111  
112 has_clause 'uniq',
113 v => 2,
114 tags => ['constraint'],
115 schema => ['bool', {}],
116 inspect_elem => 1,
117 prio => 55, # we should wait for clauses like e.g. 'each_elem' to coerce elements
118 0 ▶ subschema => sub { $_[0] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
119 allow_expr => 1,
120 0 ▶ code => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
121 0 my ($self, $cd) = @_;
122 0 $self->superclause_has_elems('uniq', $cd);
123 28 };
124  
125 has_clause 'exists',
126 v => 2,
127 tags => ['constraint'],
128 schema => ['sah::schema', {req=>1}],
129 inspect_elem => 1,
130 0 ▶ subschema => sub { $_[0] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
131 allow_expr => 0,
132 0 ▶ code => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
133 0 my ($self, $cd) = @_;
134 0 $self->superclause_has_elems('exists', $cd);
135 28 };
136  
137 # has_prop 'len';
138  
139 # has_prop 'elems';
140  
141 # has_prop 'indices';
142  
143 28 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
144 28 our $DATE = '2024-02-16'; # DATE
145 28 our $DIST = 'Data-Sah'; # DIST
146 28 our $VERSION = '0.917'; # VERSION
147  
148 28 1;
149 # ABSTRACT: HasElems role
150  
151 __END__
« Data/Sah/Compiler/perl/TH/int.pm ↑ Summary Data/Sah/Type/hash.pm »