line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use strict; |
3
|
3
|
|
|
3
|
|
1285
|
|
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
100
|
|
4
|
|
|
|
|
|
|
use Data::Sah::Util::Role 'has_clause', 'has_clause_alias'; |
5
|
3
|
|
|
3
|
|
15
|
use Role::Tiny; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
151
|
|
6
|
3
|
|
|
3
|
|
14
|
use Role::Tiny::With; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
18
|
|
7
|
3
|
|
|
3
|
|
395
|
|
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
1558
|
|
8
|
|
|
|
|
|
|
with 'Data::Sah::Type::BaseType'; |
9
|
|
|
|
|
|
|
with 'Data::Sah::Type::Comparable'; |
10
|
|
|
|
|
|
|
with 'Data::Sah::Type::HasElems'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has_clause_alias each_elem => 'of'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has_clause_alias each_index => 'each_key'; |
15
|
|
|
|
|
|
|
has_clause_alias each_elem => 'each_value'; |
16
|
|
|
|
|
|
|
has_clause_alias check_each_index => 'check_each_key'; |
17
|
|
|
|
|
|
|
has_clause_alias check_each_elem => 'check_each_value'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has_clause "keys", |
20
|
|
|
|
|
|
|
v => 2, |
21
|
|
|
|
|
|
|
tags => ['constraint'], |
22
|
|
|
|
|
|
|
schema => ['hash' => {req=>1, values => ['sah::schema', {req=>1}]}], |
23
|
|
|
|
|
|
|
inspect_elem => 1, |
24
|
|
|
|
|
|
|
subschema => sub { values %{ $_[0] } }, |
25
|
|
|
|
|
|
|
allow_expr => 0, |
26
|
|
|
|
|
|
|
attrs => { |
27
|
|
|
|
|
|
|
restrict => { |
28
|
|
|
|
|
|
|
schema => [bool => default=>1], |
29
|
|
|
|
|
|
|
allow_expr => 0, # TODO |
30
|
|
|
|
|
|
|
}, |
31
|
|
|
|
|
|
|
create_default => { |
32
|
|
|
|
|
|
|
schema => [bool => default=>1], |
33
|
|
|
|
|
|
|
allow_expr => 0, # TODO |
34
|
|
|
|
|
|
|
}, |
35
|
|
|
|
|
|
|
}, |
36
|
|
|
|
|
|
|
; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
has_clause "re_keys", |
39
|
|
|
|
|
|
|
v => 2, |
40
|
|
|
|
|
|
|
prio => 51, |
41
|
|
|
|
|
|
|
tags => ['constraint'], |
42
|
|
|
|
|
|
|
schema => ['hash' => { |
43
|
|
|
|
|
|
|
req=>1, |
44
|
|
|
|
|
|
|
keys => ['re', {req=>1}], |
45
|
|
|
|
|
|
|
values => ['sah::schema', {req=>1}], |
46
|
|
|
|
|
|
|
}], |
47
|
|
|
|
|
|
|
inspect_elem => 1, |
48
|
|
|
|
|
|
|
subschema => sub { values %{ $_[0] } }, |
49
|
|
|
|
|
|
|
allow_expr => 0, |
50
|
|
|
|
|
|
|
attrs => { |
51
|
|
|
|
|
|
|
restrict => { |
52
|
|
|
|
|
|
|
schema => [bool => default=>1], |
53
|
|
|
|
|
|
|
allow_expr => 0, # TODO |
54
|
|
|
|
|
|
|
}, |
55
|
|
|
|
|
|
|
}, |
56
|
|
|
|
|
|
|
; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
has_clause "req_keys", |
59
|
|
|
|
|
|
|
v => 2, |
60
|
|
|
|
|
|
|
tags => ['constraint'], |
61
|
|
|
|
|
|
|
schema => ['array', {req=>1, of=>['str', {req=>1}]}], |
62
|
|
|
|
|
|
|
allow_expr => 1, |
63
|
|
|
|
|
|
|
; |
64
|
|
|
|
|
|
|
has_clause_alias req_keys => 'req_all_keys'; |
65
|
|
|
|
|
|
|
has_clause_alias req_keys => 'req_all'; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
has_clause "allowed_keys", |
68
|
|
|
|
|
|
|
v => 2, |
69
|
|
|
|
|
|
|
tags => ['constraint'], |
70
|
|
|
|
|
|
|
schema => ['array', {req=>1, of=>['str', {req=>1}]}], |
71
|
|
|
|
|
|
|
allow_expr => 1, |
72
|
|
|
|
|
|
|
; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
has_clause "allowed_keys_re", |
75
|
|
|
|
|
|
|
v => 2, |
76
|
|
|
|
|
|
|
prio => 51, |
77
|
|
|
|
|
|
|
tags => ['constraint'], |
78
|
|
|
|
|
|
|
schema => ['re', {req=>1}], |
79
|
|
|
|
|
|
|
allow_expr => 1, |
80
|
|
|
|
|
|
|
; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
has_clause "forbidden_keys", |
83
|
|
|
|
|
|
|
v => 2, |
84
|
|
|
|
|
|
|
tags => ['constraint'], |
85
|
|
|
|
|
|
|
schema => ['array', {req=>1, of=>['str', {req=>1}]}], |
86
|
|
|
|
|
|
|
allow_expr => 1, |
87
|
|
|
|
|
|
|
; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
has_clause "forbidden_keys_re", |
90
|
|
|
|
|
|
|
v => 2, |
91
|
|
|
|
|
|
|
prio => 51, |
92
|
|
|
|
|
|
|
tags => ['constraint'], |
93
|
|
|
|
|
|
|
schema => ['re', {req=>1}], |
94
|
|
|
|
|
|
|
allow_expr => 1, |
95
|
|
|
|
|
|
|
; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
has_clause "choose_one_key", |
98
|
|
|
|
|
|
|
v => 2, |
99
|
|
|
|
|
|
|
prio => 50, |
100
|
|
|
|
|
|
|
tags => ['constraint'], |
101
|
|
|
|
|
|
|
schema => ['array', {req=>1, of=>['str', {req=>1}], min_len=>1}], |
102
|
|
|
|
|
|
|
allow_expr => 0, # for now |
103
|
|
|
|
|
|
|
; |
104
|
|
|
|
|
|
|
has_clause_alias choose_one_key => 'choose_one'; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
has_clause "choose_all_keys", |
107
|
|
|
|
|
|
|
v => 2, |
108
|
|
|
|
|
|
|
prio => 50, |
109
|
|
|
|
|
|
|
tags => ['constraint'], |
110
|
|
|
|
|
|
|
schema => ['array', {req=>1, of=>['str', {req=>1}], min_len=>1}], |
111
|
|
|
|
|
|
|
allow_expr => 0, # for now |
112
|
|
|
|
|
|
|
; |
113
|
|
|
|
|
|
|
has_clause_alias choose_all_keys => 'choose_all'; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
has_clause "req_one_key", |
116
|
|
|
|
|
|
|
v => 2, |
117
|
|
|
|
|
|
|
prio => 50, |
118
|
|
|
|
|
|
|
tags => ['constraint'], |
119
|
|
|
|
|
|
|
schema => ['array', {req=>1, of=>['str', {req=>1}], min_len=>1}], |
120
|
|
|
|
|
|
|
allow_expr => 0, # for now |
121
|
|
|
|
|
|
|
; |
122
|
|
|
|
|
|
|
has_clause_alias req_one_key => 'req_one'; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
has_clause "req_some_keys", |
125
|
|
|
|
|
|
|
v => 2, |
126
|
|
|
|
|
|
|
prio => 50, |
127
|
|
|
|
|
|
|
tags => ['constraint'], |
128
|
|
|
|
|
|
|
schema => ['array', { |
129
|
|
|
|
|
|
|
req => 1, |
130
|
|
|
|
|
|
|
len => 3, |
131
|
|
|
|
|
|
|
elems => [ |
132
|
|
|
|
|
|
|
[int => {req=>1, min=>0}], # min |
133
|
|
|
|
|
|
|
[int => {req=>1, min=>0}], # max |
134
|
|
|
|
|
|
|
[array => {req=>1, of=>['str', {req=>1}], min_len=>1}], # keys |
135
|
|
|
|
|
|
|
], |
136
|
|
|
|
|
|
|
}], |
137
|
|
|
|
|
|
|
allow_expr => 0, # for now |
138
|
|
|
|
|
|
|
; |
139
|
|
|
|
|
|
|
has_clause_alias req_some_keys => 'req_some'; |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
# for now we only support the first argument as str, not array[str] |
142
|
|
|
|
|
|
|
my $sch_dep = ['array', { |
143
|
|
|
|
|
|
|
req => 1, |
144
|
|
|
|
|
|
|
elems => [ |
145
|
|
|
|
|
|
|
['str', {req=>1}], |
146
|
|
|
|
|
|
|
['array', {of=>['str', {req=>1}]}], |
147
|
|
|
|
|
|
|
], |
148
|
|
|
|
|
|
|
}]; |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
has_clause "dep_any", |
151
|
|
|
|
|
|
|
v => 2, |
152
|
|
|
|
|
|
|
prio => 50, |
153
|
|
|
|
|
|
|
tags => ['constraint'], |
154
|
|
|
|
|
|
|
schema => $sch_dep, |
155
|
|
|
|
|
|
|
allow_expr => 0, # for now |
156
|
|
|
|
|
|
|
; |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
has_clause "dep_all", |
159
|
|
|
|
|
|
|
v => 2, |
160
|
|
|
|
|
|
|
prio => 50, |
161
|
|
|
|
|
|
|
tags => ['constraint'], |
162
|
|
|
|
|
|
|
schema => $sch_dep, |
163
|
|
|
|
|
|
|
allow_expr => 0, # for now |
164
|
|
|
|
|
|
|
; |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
has_clause "req_dep_any", |
167
|
|
|
|
|
|
|
v => 2, |
168
|
|
|
|
|
|
|
prio => 50, |
169
|
|
|
|
|
|
|
tags => ['constraint'], |
170
|
|
|
|
|
|
|
schema => $sch_dep, |
171
|
|
|
|
|
|
|
allow_expr => 0, # for now |
172
|
|
|
|
|
|
|
; |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
has_clause "req_dep_all", |
175
|
|
|
|
|
|
|
v => 2, |
176
|
|
|
|
|
|
|
prio => 50, |
177
|
|
|
|
|
|
|
tags => ['constraint'], |
178
|
|
|
|
|
|
|
schema => $sch_dep, |
179
|
|
|
|
|
|
|
allow_expr => 0, # for now |
180
|
|
|
|
|
|
|
; |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
# prop_alias indices => 'keys' |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
# prop_alias elems => 'values' |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
187
|
|
|
|
|
|
|
our $DATE = '2022-08-20'; # DATE |
188
|
|
|
|
|
|
|
our $DIST = 'Data-Sah'; # DIST |
189
|
|
|
|
|
|
|
our $VERSION = '0.912'; # VERSION |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
1; |
192
|
|
|
|
|
|
|
# ABSTRACT: hash type |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=pod |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=encoding UTF-8 |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=head1 NAME |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
Data::Sah::Type::hash - hash type |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head1 VERSION |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
This document describes version 0.912 of Data::Sah::Type::hash (from Perl distribution Data-Sah), released on 2022-08-20. |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=for Pod::Coverage ^(clause_.+|clausemeta_.+)$ |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=head1 HOMEPAGE |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
Please visit the project's homepage at L<https://metacpan.org/release/Data-Sah>. |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=head1 SOURCE |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
Source repository is at L<https://github.com/perlancar/perl-Data-Sah>. |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=head1 AUTHOR |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
perlancar <perlancar@cpan.org> |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=head1 CONTRIBUTING |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
To contribute, you can send patches by email/via RT, or send pull requests on |
225
|
|
|
|
|
|
|
GitHub. |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
Most of the time, you don't need to build the distribution yourself. You can |
228
|
|
|
|
|
|
|
simply modify the code, then test via: |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
% prove -l |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
If you want to build the distribution (e.g. to try to install it locally on your |
233
|
|
|
|
|
|
|
system), you can install L<Dist::Zilla>, |
234
|
|
|
|
|
|
|
L<Dist::Zilla::PluginBundle::Author::PERLANCAR>, |
235
|
|
|
|
|
|
|
L<Pod::Weaver::PluginBundle::Author::PERLANCAR>, and sometimes one or two other |
236
|
|
|
|
|
|
|
Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond |
237
|
|
|
|
|
|
|
that are considered a bug and can be reported to me. |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
This software is copyright (c) 2022, 2021, 2020, 2019, 2018, 2017, 2016, 2015, 2014, 2013, 2012 by perlancar <perlancar@cpan.org>. |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
244
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=head1 BUGS |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=Data-Sah> |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
When submitting a bug or request, please include a test-file or a |
251
|
|
|
|
|
|
|
patch to an existing test-file that illustrates the bug or desired |
252
|
|
|
|
|
|
|
feature. |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=cut |