blib/lib/Venus/Check.pm

filter: Statementstmt 95.9% 814 / 848 Branchbran 90.9% 200 / 220 Conditioncond 71.7% 38 / 53 MC/DCmcdc 50.0% 15 / 30 Subroutinesub 97.9% 144 / 147 Podpod 63.7% 51 / 80 totaltotal 91.5% 1262 / 1378 CC 136 SCAR 11.5
CC
136
Cov
94%
within
11.1
result
8.0
__ANON__
7.4
CRAP 3.2
« blib/lib/Venus/Enum.pm ↑ Summary blib/lib/Venus/Opts.pm »
1 package Venus::Check;
2  
3 25 ▶use 5.018;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 25 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 25 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 # IMPORTS
9  
10 25 ▶use Venus::Class 'attr', 'base', 'with';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 25 ▶use Venus::What;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 # INHERITS
15  
16 25 base 'Venus::Kind::Utility';
17  
18 # INTEGRATES
19  
20 25 with 'Venus::Role::Buildable';
21  
22 # ATTRIBUTES
23  
24 25 attr 'on_eval';
25  
26 # BUILDERS
27  
28 0 ▶sub build_arg {
Subroutine build_arg: not called CC=2 SCAR=17.9
Pod undocumented
29 0 my ($self, $data) = @_;
30  
31 return {
32 0 ▶ on_eval => ref $data eq 'ARRAY' ? $data : [$data],
Branch: 1 branch
BranchTrueFalseTotal
ref $data eq 'ARRAY' ? : 0 0 0
33 };
34 }
35  
36 957 ▶sub build_args {
Subroutine build_args: called CC=2 SCAR=7.1
Pod undocumented
37 957 my ($self, $data) = @_;
38  
39 957 ▶ $data->{on_eval} = [] if !$data->{on_eval};
Branch: 1 branch
BranchTrueFalseTotal
unless $data->{"on_eval"} 957 0 957
40  
41 957 return $data;
42 }
43  
44 # METHODS
45  
46 31 ▶sub any {
Subroutine any: called CC=1 SCAR=0.0
Pod documented
47 31 my ($self) = @_;
48  
49 31 ▶ push @{$self->on_eval}, sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
50 58 my ($source, $value) = @_;
51 58 return $source->pass($value, {
52 from => 'any',
53 });
54 31 };
55  
56 31 return $self;
57 }
58  
59 598 ▶sub accept {
Subroutine accept: called CC=3 SCAR=11.2
Pod documented
60 598 my ($self, $name, @args) = @_;
61  
62 598 ▶ if (!$name) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($name) 0 598 598
63 0 return $self;
64 }
65 598 ▶ if ($self->can($name)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->can($name)) { } 565 33 598
66 565 return $self->$name(@args);
67 }
68 else {
69 33 return $self->identity($name, @args);
70 }
71 }
72  
73 4 ▶sub array {
Subroutine array: called CC=1 SCAR=0.0
Pod documented
74 4 my ($self, @code) = @_;
75  
76 4 return $self->arrayref(@code);
77 }
78  
79 17 ▶sub arrayref {
Subroutine arrayref: called CC=1 SCAR=0.0
Pod documented
80 17 my ($self, @code) = @_;
81  
82 17 ▶ push @{$self->on_eval}, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
83 23 my ($source, $value) = @_;
84 23 ▶ if ($source->coded($value, 'array')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($source->coded($value, 'array')) { } 11 12 23
85 11 return $source->pass($value, {
86 from => 'arrayref',
87 });
88 }
89 else {
90 12 return $source->fail($value, {
91 from => 'arrayref',
92 expected => 'arrayref',
93 received => $source->what($value),
94 with => 'error_on_coded',
95 });
96 }
97 17 }, @code;
98  
99 17 return $self;
100 }
101  
102 8 ▶sub attributes {
Subroutine attributes: called CC=1 SCAR=0.0
Pod documented
103 8 my ($self, @pairs) = @_;
104  
105 8 ▶ push @{$self->on_eval}, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
106 8 my ($source, $value) = @_;
107 8 ▶ if ($source->coded($value, 'object')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($source->coded($value, 'object')) { } 7 1 8
108 7 return $source->pass($value, {
109 from => 'attributes',
110 });
111 }
112 else {
113 1 return $source->fail($value, {
114 from => 'attributes',
115 expected => 'object',
116 received => $source->what($value),
117 with => 'error_on_coded',
118 });
119 }
120 7 ▶ }, sub {
Subroutine __ANON__: called CC=7 SCAR=19.5
121 7 my ($source, $value) = @_;
122 7 ▶ if (@pairs % 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (@pairs % 2) 1 6 7
123 1 return $source->fail($value, {
124 from => 'attributes',
125 args => [@pairs],
126 with => 'error_on_pairs',
127 });
128 }
129 6 my $result = true;
130 6 ▶ for (my $i = 0; $i < @pairs;) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @pairs) 6 2 8
131 6 my ($key, $data) = (map $pairs[$_], $i++, $i++);
132 6 ▶ if (!$value->can($key)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($value->can($key)) 2 4 6
133 2 $result = $source->fail($value, {
134 from => 'attributes',
135 name => $key,
136 with => 'error_on_missing',
137 });
138 2 last;
139 }
140 0 ▶ my ($match, @args) = (ref $data) ? (@{$data}) : ($data);
Branch: 1 branch
BranchTrueFalseTotal
ref $data ? : 0 4 4
141 4 my $check = $source->branch($key)->accept($match, @args);
142 4 ▶ if (!$check->eval($value->$key)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($check->eval($value->$key)) 2 2 4
143 $result = $source->fail($value, {
144 branch => $check->{'$branch'},
145 2 %{$check->{'$result'}},
146 from => 'attributes',
147 });
148 2 last;
149 }
150 }
151 6 ▶ if (!$result) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $result) { } 4 2 6
152 4 return $result;
153 }
154 else {
155 2 return $source->pass($value, {
156 from => 'attributes',
157 });
158 }
159 8 };
160  
161 8 return $self;
162 }
163  
164 4 ▶sub bool {
Subroutine bool: called CC=1 SCAR=0.0
Pod documented
165 4 my ($self, @code) = @_;
166  
167 4 return $self->boolean(@code);
168 }
169  
170 19 ▶sub boolean {
Subroutine boolean: called CC=1 SCAR=0.0
Pod documented
171 19 my ($self, @code) = @_;
172  
173 19 ▶ push @{$self->on_eval}, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
174 27 my ($source, $value) = @_;
175 27 ▶ if ($source->coded($value, 'boolean')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($source->coded($value, 'boolean')) { } 12 15 27
176 12 return $source->pass($value, {
177 from => 'boolean',
178 });
179 }
180 else {
181 15 return $source->fail($value, {
182 from => 'boolean',
183 expected => 'boolean',
184 received => $source->what($value),
185 with => 'error_on_coded',
186 });
187 }
188 19 }, @code;
189  
190 19 return $self;
191 }
192  
193 288 ▶sub branch {
Subroutine branch: called CC=2 SCAR=6.9
Pod documented
194 288 my ($self, @args) = @_;
195  
196 288 my $source = $self->new;
197  
198 $source->{'$branch'} = [
199 288 ▶ ($self->{'$branch'} ? @{$self->{'$branch'}} : ()), @args
Branch: 1 branch
BranchTrueFalseTotal
$self->{'$branch'} ? : 26 262 288
200 ];
201  
202 288 return $source;
203 }
204  
205 6 ▶sub clear {
Subroutine clear: called CC=1 SCAR=0.0
Pod documented
206 6 my ($self) = @_;
207  
208 6 @{$self->on_eval} = ();
209  
210 6 delete $self->{'$branch'};
211 6 delete $self->{'$result'};
212  
213 6 return $self;
214 }
215  
216 4 ▶sub code {
Subroutine code: called CC=1 SCAR=0.0
Pod documented
217 4 my ($self, @code) = @_;
218  
219 4 return $self->coderef(@code);
220 }
221  
222 791 ▶sub coded {
Subroutine coded: called CC=2 SCAR=6.9
Pod documented
223 791 my ($self, $data, $name) = @_;
224  
225 791 require Venus::What;
226  
227 791 ▶ return Venus::What->new($data)->coded($name) ? true : false;
Branch: 1 branch
BranchTrueFalseTotal
'Venus::What'->new($data)->coded($name) ? : 466 325 791
228 }
229  
230 18 ▶sub coderef {
Subroutine coderef: called CC=1 SCAR=0.0
Pod documented
231 18 my ($self, @code) = @_;
232  
233 18 ▶ push @{$self->on_eval}, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
234 26 my ($source, $value) = @_;
235 26 ▶ if ($source->coded($value, 'code')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($source->coded($value, 'code')) { } 9 17 26
236 9 return $source->pass($value, {
237 from => 'coderef',
238 });
239 }
240 else {
241 17 return $source->fail($value, {
242 from => 'coderef',
243 expected => 'coderef',
244 received => $source->what($value),
245 with => 'error_on_coded',
246 });
247 }
248 18 }, @code;
249  
250 18 return $self;
251 }
252  
253 6 ▶sub consumes {
Subroutine consumes: called CC=1 SCAR=0.0
Pod documented
254 6 my ($self, $role) = @_;
255  
256 6 ▶ push @{$self->on_eval}, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
257 10 my ($source, $value) = @_;
258 10 ▶ if ($source->coded($value, 'object')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($source->coded($value, 'object')) { } 6 4 10
259 6 return $source->pass($value, {
260 from => 'consumes',
261 });
262 }
263 else {
264 4 return $source->fail($value, {
265 from => 'consumes',
266 expected => 'object',
267 received => $source->what($value),
268 with => 'error_on_coded',
269 });
270 }
271 6 ▶ }, sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
272 6 my ($source, $value) = @_;
273 6 ▶ if ($value->can('DOES') && $value->DOES($role)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->can('DOES') and $value->DOES($role)) { } 2 4 6
Condition66%2/3
$value->can("DOES") and $value->DOES($role)
!ll&&!rl&&r
042
MC/DC50%1/2
$value->can("DOES") and $value->DOES($role)
$value->can("DOES") $value->DOES($role)
Truth table66%2/3
A and B
A= $value->can("DOES")B= $value->DOES($role)
ABresult
0X0
100
111
274 2 return $source->pass($value, {
275 from => 'consumes',
276 });
277 }
278 else {
279 4 return $source->fail($value, {
280 from => 'consumes',
281 role => $role,
282 with => 'error_on_consumes',
283 });
284 }
285 6 };
286  
287 6 return $self;
288 }
289  
290 7 ▶sub defined {
Subroutine defined: called CC=1 SCAR=0.0
Pod documented
291 7 my ($self, @code) = @_;
292  
293 7 ▶ push @{$self->on_eval}, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
294 11 my ($source, $value) = @_;
295 11 ▶ if (CORE::defined($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) { } 6 5 11
296 6 return $source->pass($value, {
297 from => 'defined',
298 });
299 }
300 else {
301 5 return $source->fail($value, {
302 from => 'defined',
303 with => 'error_on_defined',
304 });
305 }
306 7 }, @code;
307  
308 7 return $self;
309 }
310  
311 9 ▶sub dirhandle {
Subroutine dirhandle: called CC=1 SCAR=0.0
Pod documented
312 9 my ($self, @code) = @_;
313  
314 9 ▶ push @{$self->on_eval}, sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
315 15 my ($source, $value) = @_;
316 25 ▶ if ($source->coded($value, 'scalar') && ref $value eq 'GLOB' && do{no warnings 'io'; -d $value}) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
if ($source->coded($value, 'scalar') and ref $value eq 'GLOB' and do { BEGIN {${^WARNING_BITS} = "\x55\x01\x00\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x45\x55\x55\x55\x55\x55\x55\x55\x55"} -d $value }) { } 4 11 15
Condition83%5/6
$source->coded($value, "scalar") and ref $value eq "GLOB" and do { BEGIN {${^WARNING_BITS} = "\x55\x01\x00\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x45\x55\x55\x55\x55\x55\x55\x55\x55"} -d $value }
!ll&&!rl&&r
294
$source->coded($value, "scalar") and ref $value eq "GLOB"
!ll&&!rl&&r
2013
MC/DC66%2/3
$source->coded($value, "scalar") and ref $value eq "GLOB" and do { BEGIN {${^WARNING_BITS} = "\x55\x01\x00\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x45\x55\x55\x55\x55\x55\x55\x55\x55"} -d $value }
$source->coded($value, "scalar") ref $value eq "GLOB" do { BEGIN {${^WARNING_BITS} = "\x55\x01\x00\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x45\x55\x55\x55\x55\x55\x55\x55\x55"} -d $value }
Truth table75%3/4
A and B and C
A= $source->coded($value, "scalar")B= ref $value eq "GLOB"C= do { BEGIN {${^WARNING_BITS} = "\x55\x01\x00\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x45\x55\x55\x55\x55\x55\x55\x55\x55"} -d $value }
ABCresult
0XX0
10X0
1100
1111
317 4 return $source->pass($value, {
318 from => 'dirhandle',
319 });
320 }
321 else {
322 11 return $source->fail($value, {
323 from => 'dirhandle',
324 expected => 'dirhandle',
325 received => $source->what($value),
326 with => 'error_on_dirhandle',
327 });
328 }
329 9 }, @code;
330  
331 9 return $self;
332 }
333  
334 52 ▶sub either {
Subroutine either: called CC=1 SCAR=0.0
Pod documented
335 52 my ($self, @data) = @_;
336  
337 52 ▶ push @{$self->on_eval}, sub {
Subroutine __ANON__: called CC=7 SCAR=19.5
338 99 my ($source, $value) = @_;
339 99 my $returns;
340 my @errors;
341 99 my @results;
342 99 ▶ for (my $i = 0; $i < @data; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @data) 158 27 185
343 158 ▶ my ($match, @args) = (ref $data[$i]) ? (@{$data[$i]}) : ($data[$i]);
Branch: 1 branch
BranchTrueFalseTotal
ref $data[$i] ? : 19 139 158
344 158 my $check = $source->branch->do('accept', $match, @args);
345 158 ▶ if ($check->eval($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($check->eval($value)) { } 72 86 158
346 $returns = $source->pass($value, {
347 from => 'either',
348 ($check->{'$branch'} ? (branch => $check->{'$branch'}) : ()),
349 72 ▶ %{$check->{'$result'}},
Branch: 1 branch
BranchTrueFalseTotal
$check->{'$branch'} ? : 72 0 72
350 });
351 72 push @results, $source->{'$result'};
352 72 last;
353 }
354 else {
355 $returns = $source->fail($value, {
356 from => 'either',
357 ($check->{'$branch'} ? (branch => $check->{'$branch'}) : ()),
358 86 ▶ %{$check->{'$result'}},
Branch: 1 branch
BranchTrueFalseTotal
$check->{'$branch'} ? : 86 0 86
359 });
360 86 push @results, $source->{'$result'};
361 86 push @errors, $source->catch('result')->render;
362 }
363 }
364 99 ▶ if ($returns) {
Branch: 1 branch
BranchTrueFalseTotal
if ($returns) { } 72 27 99
365 72 return $returns;
366 }
367 else {
368 27 return $self->fail($value, {
369 from => 'either',
370 with => 'error_on_either',
371 results => [@results],
372 errors => [@errors],
373 });
374 }
375 52 };
376  
377 52 return $self;
378 }
379  
380 10 ▶sub enum {
Subroutine enum: called CC=1 SCAR=0.0
Pod documented
381 10 my ($self, @data) = @_;
382  
383 10 ▶ push @{$self->on_eval}, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
384 13 my ($source, $value) = @_;
385 13 ▶ if (CORE::defined($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) { } 12 1 13
386 12 return $source->pass($value, {
387 from => 'enum',
388 });
389 }
390 else {
391 1 return $source->fail($value, {
392 from => 'enum',
393 with => 'error_on_defined',
394 });
395 }
396 12 ▶ }, sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
397 12 my ($source, $value) = @_;
398 12 my $result;
399 12 for my $item (@data) {
400 23 ▶ if ($value eq $item) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value eq $item) { } 7 16 23
401 7 $result = $source->pass($value, {
402 from => 'enum',
403 });
404 7 last;
405 }
406 else {
407 16 $result = $source->fail($value, {
408 from => 'enum',
409 with => 'error_on_enum',
410 enum => [@data],
411 });
412 }
413 }
414 12 return $result;
415 10 };
416  
417 10 return $self;
418 }
419  
420 1125 ▶sub eval {
Subroutine eval: called CC=4 SCAR=13.9
Pod documented
421 1125 my ($self, $data) = @_;
422  
423 1125 delete $self->{'$result'};
424  
425 1125 my $result = false;
426  
427 1125 for my $callback (@{$self->on_eval}) {
428 1470 local $_ = $data;
429 1470 ▶ $result = $self->$callback($data) ? true : false;
Branch: 1 branch
BranchTrueFalseTotal
$self->$callback($data) ? : 976 494 1470
430 1470 ▶ last if !$result;
Branch: 1 branch
BranchTrueFalseTotal
unless $result 494 976 1470
431 }
432  
433 1125 return $result;
434 }
435  
436 2 ▶sub evaled {
Subroutine evaled: called CC=3 SCAR=11.0
Pod documented
437 2 my ($self) = @_;
438  
439 2 my $passed = $self->passed;
440 2 my $failed = $self->failed;
441  
442 2 ▶ return !$passed && !$failed ? false : true;
Branch: 1 branch
BranchTrueFalseTotal
!($passed || $failed) ? : 1 1 2
Condition66%2/3
$passed || $failed
l!l&&r!l&&!r
101
MC/DC50%1/2
$passed || $failed
$passed $failed
Truth table66%2/3
A || B
A= $passedB= $failed
ABresult
1X1
011
000
443 }
444  
445 2 ▶sub evaler {
Subroutine evaler: called CC=1 SCAR=0.0
Pod documented
446 2 my ($self, @args) = @_;
447  
448 2 return $self->defer('eval', @args);
449 }
450  
451 595 ▶sub fail {
Subroutine fail: called CC=2 SCAR=7.0
Pod documented
452 595 my ($self, $data, $meta) = @_;
453  
454 595 ▶ my $from = $meta->{from} || 'callback';
Condition50%1/2
$meta->{'from'} || 'callback'
l!l
5950
MC/DC0%0/1
$meta->{'from'} || 'callback'
$meta->{'from'}
Truth table50%1/2
A
A= $meta->{'from'}
Aresult
11
00
455 595 my $with = $meta->{with};
456 595 my $okay = false;
457  
458 595 $self->{'$result'} = {
459 %$meta,
460 data => $data,
461 from => $from,
462 okay => $okay,
463 with => $with,
464 };
465  
466 595 return $okay;
467 }
468  
469 5 ▶sub failed {
Subroutine failed: called CC=3 SCAR=11.0
Pod documented
470 5 my ($self) = @_;
471  
472 5 my $result = $self->{'$result'};
473  
474 5 ▶ return $result ? ($result->{okay} ? false : true) : false;
Branch: 2 branches
BranchTrueFalseTotal
$result ? : 3 2 5
$result->{'okay'} ? : 2 1 3
475 }
476  
477 9 ▶sub filehandle {
Subroutine filehandle: called CC=1 SCAR=0.0
Pod documented
478 9 my ($self, @code) = @_;
479  
480 9 ▶ push @{$self->on_eval}, sub {
Subroutine __ANON__: called CC=5 SCAR=16.1
481 15 my ($source, $value) = @_;
482 15 ▶ if ($source->coded($value, 'scalar') && ref $value eq 'GLOB' && defined(fileno($value)) && !-d $value) {
Branch: 1 branch
BranchTrueFalseTotal
if ($source->coded($value, 'scalar') and ref $value eq 'GLOB' and defined fileno $value and not -d $value) { } 10 5 15
Condition88%8/9
$source->coded($value, "scalar") and ref $value eq "GLOB" and defined fileno $value and not -d $value
!ll&&!rl&&r
4110
$source->coded($value, "scalar") and ref $value eq "GLOB" and defined fileno $value
!ll&&!rl&&r
2211
$source->coded($value, "scalar") and ref $value eq "GLOB"
!ll&&!rl&&r
2013
MC/DC75%3/4
$source->coded($value, "scalar") and ref $value eq "GLOB" and defined fileno $value and not -d $value
$source->coded($value, "scalar") ref $value eq "GLOB" defined fileno $value not -d $value
Truth table80%4/5
A and B and C and not(D)
A= $source->coded($value, "scalar")B= ref $value eq "GLOB"C= defined fileno $valueD= not -d $value
ABCDresult
0XXX0
10XX0
110X0
11100
11111
483 10 return $source->pass($value, {
484 from => 'filehandle',
485 });
486 }
487 else {
488 5 return $source->fail($value, {
489 from => 'filehandle',
490 expected => 'filehandle',
491 received => $source->what($value),
492 with => 'error_on_filehandle',
493 });
494 }
495 9 }, @code;
496  
497 9 return $self;
498 }
499  
500 51 ▶sub float {
Subroutine float: called CC=1 SCAR=0.0
Pod documented
501 51 my ($self, @code) = @_;
502  
503 51 ▶ push @{$self->on_eval}, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
504 63 my ($source, $value) = @_;
505 63 ▶ if ($source->coded($value, 'float')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($source->coded($value, 'float')) { } 41 22 63
506 41 return $source->pass($value, {
507 from => 'float',
508 });
509 }
510 else {
511 22 return $source->fail($value, {
512 from => 'float',
513 expected => 'float',
514 received => $source->what($value),
515 with => 'error_on_coded',
516 });
517 }
518 51 }, @code;
519  
520 51 return $self;
521 }
522  
523 9 ▶sub glob {
Subroutine glob: called CC=1 SCAR=0.0
Pod documented
524 9 my ($self, @code) = @_;
525  
526 9 ▶ push @{$self->on_eval}, sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
527 12 my ($source, $value) = @_;
528 12 ▶ if ($source->coded($value, 'scalar') && ref $value eq 'GLOB') {
Branch: 1 branch
BranchTrueFalseTotal
if ($source->coded($value, 'scalar') and ref $value eq 'GLOB') { } 4 8 12
Condition66%2/3
$source->coded($value, "scalar") and ref $value eq "GLOB"
!ll&&!rl&&r
804
MC/DC50%1/2
$source->coded($value, "scalar") and ref $value eq "GLOB"
$source->coded($value, "scalar") ref $value eq "GLOB"
Truth table66%2/3
A and B
A= $source->coded($value, "scalar")B= ref $value eq "GLOB"
ABresult
0X0
100
111
529 4 return $source->pass($value, {
530 from => 'glob',
531 });
532 }
533 else {
534 8 return $source->fail($value, {
535 from => 'glob',
536 expected => 'typeglob',
537 received => $source->what($value),
538 with => 'error_on_typeglob',
539 });
540 }
541 9 }, @code;
542  
543 9 return $self;
544 }
545  
546 4 ▶sub hash {
Subroutine hash: called CC=1 SCAR=0.0
Pod documented
547 4 my ($self, @code) = @_;
548  
549 4 return $self->hashref(@code);
550 }
551  
552 10 ▶sub hashkeys {
Subroutine hashkeys: called CC=1 SCAR=0.0
Pod documented
553 10 my ($self, @pairs) = @_;
554  
555 10 ▶ push @{$self->on_eval}, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
556 11 my ($source, $value) = @_;
557 11 ▶ if (CORE::defined($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) { } 10 1 11
558 10 return $source->pass($value, {
559 from => 'hashkeys',
560 });
561 }
562 else {
563 1 return $source->fail($value, {
564 from => 'hashkeys',
565 with => 'error_on_defined',
566 });
567 }
568 10 ▶ }, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
569 10 my ($source, $value) = @_;
570 10 ▶ if (UNIVERSAL::isa($value, 'HASH')) {
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::isa($value, 'HASH')) { } 8 2 10
571 8 return $source->pass($value, {
572 from => 'hashkeys',
573 });
574 }
575 else {
576 2 return $source->fail($value, {
577 from => 'hashkeys',
578 with => 'error_on_hashref',
579 });
580 }
581 8 ▶ }, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
582 8 my ($source, $value) = @_;
583 8 ▶ if ((CORE::keys %{$value}) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (keys %{$value;} > 0) { } 5 3 8
584 5 return $source->pass($value, {
585 from => 'hashkeys',
586 });
587 }
588 else {
589 3 return $source->fail($value, {
590 from => 'hashkeys',
591 with => 'error_on_hashref_empty',
592 });
593 }
594 5 ▶ }, sub {
Subroutine __ANON__: called CC=7 SCAR=20.0
595 5 my ($source, $value) = @_;
596 5 ▶ if (@pairs % 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (@pairs % 2) 2 3 5
597 2 return $source->fail($value, {
598 from => 'hashkeys',
599 args => [@pairs],
600 with => 'error_on_pairs',
601 });
602 }
603 3 my $result = true;
604 3 ▶ for (my $i = 0; $i < @pairs;) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @pairs) 3 2 5
605 3 my ($key, $data) = (map $pairs[$_], $i++, $i++);
606 3 ▶ if (!exists $value->{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $value->{$key}) 1 2 3
607 1 $result = $source->fail($value, {
608 from => 'hashkeys',
609 name => $key,
610 with => 'error_on_missing',
611 });
612 1 last;
613 }
614 0 ▶ my ($match, @args) = (ref $data) ? (@{$data}) : ($data);
Branch: 1 branch
BranchTrueFalseTotal
ref $data ? : 0 2 2
615 2 my $check = $source->branch($key)->accept($match, @args);
616 2 ▶ if (!$check->eval($value->{$key})) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($check->eval($value->{$key})) 0 2 2
617 $result = $source->fail($value, {
618 branch => $check->{'$branch'},
619 0 %{$check->{'$result'}},
620 from => 'hashkeys',
621 });
622 0 last;
623 }
624 }
625 3 ▶ if (!$result) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $result) { } 1 2 3
626 1 return $result;
627 }
628 else {
629 2 return $source->pass($value, {
630 from => 'hashkeys',
631 });
632 }
633 10 };
634  
635 10 return $self;
636 }
637  
638 15 ▶sub hashref {
Subroutine hashref: called CC=1 SCAR=0.0
Pod documented
639 15 my ($self, @code) = @_;
640  
641 15 ▶ push @{$self->on_eval}, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
642 21 my ($source, $value) = @_;
643 21 ▶ if ($source->coded($value, 'hash')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($source->coded($value, 'hash')) { } 8 13 21
644 8 return $source->pass($value, {
645 from => 'hashref',
646 });
647 }
648 else {
649 13 return $source->fail($value, {
650 from => 'hashref',
651 expected => 'hashref',
652 received => $source->what($value),
653 with => 'error_on_coded',
654 });
655 }
656 15 }, @code;
657  
658 15 return $self;
659 }
660  
661 5 ▶sub includes {
Subroutine includes: called CC=1 SCAR=0.0
Pod documented
662 5 my ($self, @data) = @_;
663  
664 5 ▶ push @{$self->on_eval}, sub {
Subroutine __ANON__: called CC=7 SCAR=19.6
665 7 my ($source, $value) = @_;
666 7 my $returns;
667 my @errors;
668 7 my @results;
669 7 ▶ for (my $i = 0; $i < @data; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @data) 10 3 13
670 0 ▶ my ($match, @args) = (ref $data[$i]) ? (@{$data[$i]}) : ($data[$i]);
Branch: 1 branch
BranchTrueFalseTotal
ref $data[$i] ? : 0 10 10
671 10 my $check = $source->branch->do('accept', $match, @args);
672 10 ▶ if ($check->eval($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($check->eval($value)) { } 6 4 10
673 $returns = $source->pass($value, {
674 from => 'either',
675 ($check->{'$branch'} ? (branch => $check->{'$branch'}) : ()),
676 6 ▶ %{$check->{'$result'}},
Branch: 1 branch
BranchTrueFalseTotal
$check->{'$branch'} ? : 6 0 6
677 });
678 6 push @results, $source->{'$result'};
679 }
680 else {
681 $returns = $source->fail($value, {
682 from => 'either',
683 ($check->{'$branch'} ? (branch => $check->{'$branch'}) : ()),
684 4 ▶ %{$check->{'$result'}},
Branch: 1 branch
BranchTrueFalseTotal
$check->{'$branch'} ? : 4 0 4
685 });
686 4 push @results, $source->{'$result'};
687 4 push @errors, $source->catch('result')->render;
688 4 last;
689 }
690 }
691 7 ▶ if (@errors) {
Branch: 1 branch
BranchTrueFalseTotal
if (@errors) { } 4 3 7
692 4 return $self->fail($value, {
693 from => 'includes',
694 with => 'error_on_includes',
695 results => [@results],
696 errors => [@errors],
697 });
698 }
699 else {
700 3 return $returns;
701 }
702 5 };
703  
704 5 return $self;
705 }
706  
707 41 ▶sub identity {
Subroutine identity: called CC=1 SCAR=0.0
Pod documented
708 41 my ($self, $name) = @_;
709  
710 41 ▶ push @{$self->on_eval}, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
711 66 my ($source, $value) = @_;
712 66 ▶ if ($source->coded($value, 'object')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($source->coded($value, 'object')) { } 49 17 66
713 49 return $source->pass($value, {
714 from => 'identity',
715 });
716 }
717 else {
718 17 return $source->fail($value, {
719 from => 'identity',
720 expected => 'object',
721 received => $source->what($value),
722 with => 'error_on_coded',
723 });
724 }
725 49 ▶ }, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
726 49 my ($source, $value) = @_;
727 49 ▶ if ($value->isa($name)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->isa($name)) { } 42 7 49
728 42 return $source->pass($value, {
729 from => 'identity',
730 });
731 }
732 else {
733 7 return $source->fail($value, {
734 from => 'identity',
735 with => 'error_on_identity',
736 name => $name,
737 });
738 }
739 41 };
740  
741 41 return $self;
742 }
743  
744 6 ▶sub inherits {
Subroutine inherits: called CC=1 SCAR=0.0
Pod documented
745 6 my ($self, $name) = @_;
746  
747 6 ▶ push @{$self->on_eval}, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
748 10 my ($source, $value) = @_;
749 10 ▶ if ($source->coded($value, 'object')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($source->coded($value, 'object')) { } 6 4 10
750 6 return $source->pass($value, {
751 from => 'inherits',
752 });
753 }
754 else {
755 4 return $source->fail($value, {
756 from => 'inherits',
757 expected => 'object',
758 received => $source->what($value),
759 with => 'error_on_coded',
760 });
761 }
762 6 ▶ }, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
763 6 my ($source, $value) = @_;
764 6 ▶ if ($value->isa($name)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->isa($name)) { } 2 4 6
765 2 return $source->pass($value, {
766 from => 'inherits',
767 });
768 }
769 else {
770 4 return $source->fail($value, {
771 from => 'inherits',
772 with => 'error_on_inherits',
773 name => $name,
774 });
775 }
776 6 };
777  
778 6 return $self;
779 }
780  
781 5 ▶sub integrates {
Subroutine integrates: called CC=1 SCAR=0.0
Pod documented
782 5 my ($self, $role) = @_;
783  
784 5 ▶ push @{$self->on_eval}, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
785 9 my ($source, $value) = @_;
786 9 ▶ if ($source->coded($value, 'object')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($source->coded($value, 'object')) { } 5 4 9
787 5 return $source->pass($value, {
788 from => 'integrates',
789 });
790 }
791 else {
792 4 return $source->fail($value, {
793 from => 'integrates',
794 expected => 'object',
795 received => $source->what($value),
796 with => 'error_on_coded',
797 });
798 }
799 5 ▶ }, sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
800 5 my ($source, $value) = @_;
801 5 ▶ if ($value->can('DOES') && $value->DOES($role)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->can('DOES') and $value->DOES($role)) { } 2 3 5
Condition66%2/3
$value->can("DOES") and $value->DOES($role)
!ll&&!rl&&r
032
MC/DC50%1/2
$value->can("DOES") and $value->DOES($role)
$value->can("DOES") $value->DOES($role)
Truth table66%2/3
A and B
A= $value->can("DOES")B= $value->DOES($role)
ABresult
0X0
100
111
802 2 return $source->pass($value, {
803 from => 'integrates',
804 });
805 }
806 else {
807 3 return $source->fail($value, {
808 from => 'integrates',
809 role => $role,
810 with => 'error_on_consumes',
811 });
812 }
813 5 };
814  
815 5 return $self;
816 }
817  
818 5 ▶sub maybe {
Subroutine maybe: called CC=2 SCAR=7.1
Pod documented
819 5 my ($self, $match, @args) = @_;
820  
821 5 ▶ $self->either('undef', ($match ? [$match, @args] : ()));
Branch: 1 branch
BranchTrueFalseTotal
$match ? : 5 0 5
822  
823 5 return $self;
824 }
825  
826 119 ▶sub number {
Subroutine number: called CC=1 SCAR=0.0
Pod documented
827 119 my ($self, @code) = @_;
828  
829 119 ▶ push @{$self->on_eval}, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
830 165 my ($source, $value) = @_;
831 165 ▶ if ($source->coded($value, 'number')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($source->coded($value, 'number')) { } 111 54 165
832 111 return $source->pass($value, {
833 from => 'number',
834 });
835 }
836 else {
837 54 return $source->fail($value, {
838 from => 'number',
839 expected => 'number',
840 received => $source->what($value),
841 with => 'error_on_coded',
842 });
843 }
844 119 }, @code;
845  
846 119 return $self;
847 }
848  
849 16 ▶sub object {
Subroutine object: called CC=1 SCAR=0.0
Pod documented
850 16 my ($self, @code) = @_;
851  
852 16 ▶ push @{$self->on_eval}, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
853 29 my ($source, $value) = @_;
854 29 ▶ if ($source->coded($value, 'object')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($source->coded($value, 'object')) { } 12 17 29
855 12 return $source->pass($value, {
856 from => 'object',
857 });
858 }
859 else {
860 17 return $source->fail($value, {
861 from => 'object',
862 expected => 'object',
863 received => $source->what($value),
864 with => 'error_on_coded',
865 });
866 }
867 16 }, @code;
868  
869 16 return $self;
870 }
871  
872 12 ▶sub package {
Subroutine package: called CC=1 SCAR=0.0
Pod documented
873 12 my ($self, @code) = @_;
874  
875 12 ▶ push @{$self->on_eval}, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
876 15 my ($source, $value) = @_;
877 15 ▶ if ($source->coded($value, 'string')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($source->coded($value, 'string')) { } 11 4 15
878 11 return $source->pass($value, {
879 from => 'package',
880 });
881 }
882 else {
883 4 return $source->fail($value, {
884 from => 'package',
885 expected => 'string',
886 received => $source->what($value),
887 with => 'error_on_coded',
888 });
889 }
890 11 ▶ }, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
891 11 my ($source, $value) = @_;
892 11 ▶ if ($value =~ /^[A-Z](?:(?:\w|::)*[a-zA-Z0-9])?$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /^[A-Z](?:(?:\w|::)*[a-zA-Z0-9])?$/u) { } 9 2 11
893 9 return $source->pass($value, {
894 from => 'package',
895 });
896 }
897 else {
898 2 return $source->fail($value, {
899 from => 'package',
900 with => 'error_on_package',
901 });
902 }
903 9 ▶ }, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
904 9 my ($source, $value) = @_;
905 9 require Venus::Space;
906 9 ▶ if (Venus::Space->new($value)->loaded) {
Branch: 1 branch
BranchTrueFalseTotal
if ('Venus::Space'->new($value)->loaded) { } 4 5 9
907 4 return $source->pass($value, {
908 from => 'package',
909 });
910 }
911 else {
912 5 return $source->fail($value, {
913 from => 'package',
914 with => 'error_on_package_loaded',
915 });
916 }
917 12 }, @code;
918  
919 12 return $self;
920 }
921  
922 978 ▶sub pass {
Subroutine pass: called CC=2 SCAR=7.0
Pod documented
923 978 my ($self, $data, $meta) = @_;
924  
925 978 ▶ my $from = $meta->{from} || 'callback';
Condition50%1/2
$meta->{'from'} || 'callback'
l!l
9780
MC/DC0%0/1
$meta->{'from'} || 'callback'
$meta->{'from'}
Truth table50%1/2
A
A= $meta->{'from'}
Aresult
11
00
926 978 my $with = $meta->{with};
927 978 my $okay = true;
928  
929 978 $self->{'$result'} = {
930 %$meta,
931 data => $data,
932 from => $from,
933 okay => $okay,
934 with => $with,
935 };
936  
937 978 return $okay;
938 }
939  
940 5 ▶sub passed {
Subroutine passed: called CC=3 SCAR=11.0
Pod documented
941 5 my ($self) = @_;
942  
943 5 my $result = $self->{'$result'};
944  
945 5 ▶ return $result ? ($result->{okay} ? true : false) : false;
Branch: 2 branches
BranchTrueFalseTotal
$result ? : 3 2 5
$result->{'okay'} ? : 2 1 3
946 }
947  
948 10 ▶sub reference {
Subroutine reference: called CC=1 SCAR=0.0
Pod documented
949 10 my ($self, @code) = @_;
950  
951 10 ▶ push @{$self->on_eval}, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
952 16 my ($source, $value) = @_;
953 16 ▶ if (CORE::defined($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) { } 15 1 16
954 15 return $source->pass($value, {
955 from => 'reference',
956 });
957 }
958 else {
959 1 return $source->fail($value, {
960 from => 'reference',
961 with => 'error_on_defined',
962 });
963 }
964 15 ▶ }, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
965 15 my ($source, $value) = @_;
966 15 ▶ if (ref($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value) { } 7 8 15
967 7 return $source->pass($value, {
968 from => 'reference',
969 });
970 }
971 else {
972 8 return $source->fail($value, {
973 from => 'reference',
974 with => 'error_on_reference',
975 });
976 }
977 10 }, @code;
978  
979 10 return $self;
980 }
981  
982 8 ▶sub regexp {
Subroutine regexp: called CC=1 SCAR=0.0
Pod documented
983 8 my ($self, @code) = @_;
984  
985 8 ▶ push @{$self->on_eval}, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
986 14 my ($source, $value) = @_;
987 14 ▶ if ($source->coded($value, 'regexp')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($source->coded($value, 'regexp')) { } 4 10 14
988 4 return $source->pass($value, {
989 from => 'regexp',
990 });
991 }
992 else {
993 10 return $source->fail($value, {
994 from => 'regexp',
995 expected => 'regexp',
996 received => $source->what($value),
997 with => 'error_on_coded',
998 });
999 }
1000 8 }, @code;
1001  
1002 8 return $self;
1003 }
1004  
1005 238 ▶sub result {
Subroutine result: called CC=8 SCAR=20.8
Pod documented
1006 238 my ($self, @data) = @_;
1007  
1008 238 ▶ my $eval = $self->eval(@data) if @data;
Branch: 1 branch
BranchTrueFalseTotal
if @data 130 108 238
1009  
1010 238 my $result = $self->{'$result'};
1011  
1012 238 ▶ return undef if !defined $result;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $result 0 238 238
1013  
1014 238 my $data = $result->{data};
1015 238 ▶ my $okay = (delete $result->{okay}) || $eval;
Condition66%2/3
delete $result->{'okay'} || $eval
l!l&&r!l&&!r
400198
MC/DC50%1/2
delete $result->{'okay'} || $eval
delete $result->{'okay'} $eval
Truth table66%2/3
A || B
A= delete $result->{'okay'}B= $eval
ABresult
1X1
011
000
1016 238 ▶ my $with = (delete $result->{with}) || 'error_on_unknown';
Condition100%2/2
delete $result->{'with'} || 'error_on_unknown'
l!l
19840
MC/DC100%1/1
delete $result->{'with'} || 'error_on_unknown'
delete $result->{'with'}
Truth table100%2/2
A
A= delete $result->{'with'}
Aresult
11
00
1017  
1018 $result->{at} = $result->{'branch'}
1019 238 ▶ ? join('.', '', @{$result->{'branch'}}) || '.' : '.';
Branch: 1 branch
BranchTrueFalseTotal
$result->{'branch'} ? : 98 140 238
Condition100%2/2
join ".", "", @{$result->{"branch"};} or "."
l!l
791
MC/DC100%1/1
join ".", "", @{$result->{"branch"};} or "."
join ".", "", @{$result->{"branch"};}
Truth table100%2/2
A
A= join ".", "", @{$result->{"branch"};}
Aresult
11
00
1020  
1021 238 ▶ return $okay ? $data : $self->$with($result)->capture(@data)->throw;
Branch: 1 branch
BranchTrueFalseTotal
$okay ? : 40 198 238
1022 }
1023  
1024 5 ▶sub routines {
Subroutine routines: called CC=1 SCAR=0.0
Pod documented
1025 5 my ($self, @data) = @_;
1026  
1027 5 ▶ push @{$self->on_eval}, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
1028 10 my ($source, $value) = @_;
1029 10 ▶ if ($source->coded($value, 'object')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($source->coded($value, 'object')) { } 5 5 10
1030 5 return $source->pass($value, {
1031 from => 'routines',
1032 });
1033 }
1034 else {
1035 5 return $source->fail($value, {
1036 from => 'routines',
1037 expected => 'object',
1038 received => $source->what($value),
1039 with => 'error_on_coded',
1040 });
1041 }
1042 5 ▶ }, sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
1043 5 my ($source, $value) = @_;
1044 5 my $result;
1045 5 for my $item (@data) {
1046 5 ▶ if ($value->can($item)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->can($item)) { } 2 3 5
1047 2 $result = $source->pass($value, {
1048 from => 'routines',
1049 });
1050 }
1051 else {
1052 3 $result = $source->fail($value, {
1053 from => 'routines',
1054 name => $item,
1055 with => 'error_on_missing',
1056 });
1057 3 last;
1058 }
1059 }
1060 5 return $result;
1061 5 };
1062  
1063 5 return $self;
1064 }
1065  
1066 4 ▶sub scalar {
Subroutine scalar: called CC=1 SCAR=0.0
Pod documented
1067 4 my ($self, @code) = @_;
1068  
1069 4 return $self->scalarref(@code);
1070 }
1071  
1072 12 ▶sub scalarref {
Subroutine scalarref: called CC=1 SCAR=0.0
Pod documented
1073 12 my ($self, @code) = @_;
1074  
1075 12 ▶ push @{$self->on_eval}, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
1076 22 my ($source, $value) = @_;
1077 22 ▶ if ($source->coded($value, 'scalar')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($source->coded($value, 'scalar')) { } 8 14 22
1078 8 return $source->pass($value, {
1079 from => 'scalarref',
1080 });
1081 }
1082 else {
1083 14 return $source->fail($value, {
1084 from => 'scalarref',
1085 expected => 'scalarref',
1086 received => $source->what($value),
1087 with => 'error_on_coded',
1088 });
1089 }
1090 12 }, @code;
1091  
1092 12 return $self;
1093 }
1094  
1095 206 ▶sub string {
Subroutine string: called CC=1 SCAR=0.0
Pod documented
1096 206 my ($self, @code) = @_;
1097  
1098 206 ▶ push @{$self->on_eval}, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
1099 206 my ($source, $value) = @_;
1100 206 ▶ if ($source->coded($value, 'string')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($source->coded($value, 'string')) { } 125 81 206
1101 125 return $source->pass($value, {
1102 from => 'string',
1103 });
1104 }
1105 else {
1106 81 return $source->fail($value, {
1107 from => 'string',
1108 expected => 'string',
1109 received => $source->what($value),
1110 with => 'error_on_coded',
1111 });
1112 }
1113 206 }, @code;
1114  
1115 206 return $self;
1116 }
1117  
1118 9 ▶sub tuple {
Subroutine tuple: called CC=1 SCAR=0.0
Pod documented
1119 9 my ($self, @data) = @_;
1120  
1121 9 ▶ push @{$self->on_eval}, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
1122 18 my ($source, $value) = @_;
1123 18 ▶ if (CORE::defined($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) { } 17 1 18
1124 17 return $source->pass($value, {
1125 from => 'tuple',
1126 });
1127 }
1128 else {
1129 1 return $source->fail($value, {
1130 from => 'tuple',
1131 with => 'error_on_defined',
1132 });
1133 }
1134 17 ▶ }, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
1135 17 my ($source, $value) = @_;
1136 17 ▶ if (UNIVERSAL::isa($value, 'ARRAY')) {
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::isa($value, 'ARRAY')) { } 11 6 17
1137 11 return $source->pass($value, {
1138 from => 'tuple',
1139 });
1140 }
1141 else {
1142 6 return $source->fail($value, {
1143 from => 'tuple',
1144 with => 'error_on_arrayref',
1145 });
1146 }
1147 11 ▶ }, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
1148 11 my ($source, $value) = @_;
1149 11 ▶ if (@data == @{$value}) {
Branch: 1 branch
BranchTrueFalseTotal
if (@data == @{$value;}) { } 7 4 11
1150 7 return $source->pass($value, {
1151 from => 'tuple',
1152 });
1153 }
1154 else {
1155 4 return $source->fail($value, {
1156 from => 'tuple',
1157 with => 'error_on_arrayref_count',
1158 });
1159 }
1160 7 ▶ }, sub {
Subroutine __ANON__: called CC=5 SCAR=16.1
1161 7 my ($source, $value) = @_;
1162 7 my $result = true;
1163 7 ▶ for (my $i = 0; $i < @data; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @data) 15 4 19
1164 0 ▶ my ($match, @args) = (ref $data[$i]) ? (@{$data[$i]}) : ($data[$i]);
Branch: 1 branch
BranchTrueFalseTotal
ref $data[$i] ? : 0 15 15
1165 15 my $check = $source->branch($i)->accept($match, @args);
1166 15 ▶ if (!$check->eval($value->[$i])) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($check->eval($value->[$i])) 3 12 15
1167 $result = $source->fail($value, {
1168 branch => $check->{'$branch'},
1169 3 %{$check->{'$result'}},
1170 from => 'tuple',
1171 });
1172 3 last;
1173 }
1174 }
1175 7 ▶ if (!$result) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $result) { } 3 4 7
1176 3 return $result;
1177 }
1178 else {
1179 4 return $self->pass($value, {
1180 from => 'tuple',
1181 });
1182 }
1183 9 };
1184  
1185 9 return $self;
1186 }
1187  
1188 341 ▶sub what {
Subroutine what: called CC=2 SCAR=7.0
Pod documented
1189 341 my ($self, $value) = @_;
1190  
1191 341 my $aliases = {
1192 array => 'arrayref',
1193 code => 'coderef',
1194 hash => 'hashref',
1195 regexp => 'regexpref',
1196 scalar => 'scalarref',
1197 };
1198  
1199 341 my $identity = lc(Venus::What->new(value => $value)->identify);
1200  
1201 341 ▶ return $aliases->{$identity} || $identity;
Condition66%2/3
$aliases->{$identity} || $identity
l!l&&r!l&&!r
952460
MC/DC0%0/2
$aliases->{$identity} || $identity
$aliases->{$identity} $identity
Truth table66%2/3
A || B
A= $aliases->{$identity}B= $identity
ABresult
1X1
011
000
1202 }
1203  
1204 18 ▶sub undef {
Subroutine undef: called CC=1 SCAR=0.0
Pod documented
1205 18 my ($self, @code) = @_;
1206  
1207 18 ▶ push @{$self->on_eval}, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
1208 23 my ($source, $value) = @_;
1209 23 ▶ if ($source->coded($value, 'undef')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($source->coded($value, 'undef')) { } 5 18 23
1210 5 return $source->pass($value, {
1211 from => 'undef',
1212 });
1213 }
1214 else {
1215 18 return $source->fail($value, {
1216 from => 'undef',
1217 expected => 'undef',
1218 received => $source->what($value),
1219 with => 'error_on_coded',
1220 });
1221 }
1222 18 }, @code;
1223  
1224 18 return $self;
1225 }
1226  
1227 12 ▶sub value {
Subroutine value: called CC=1 SCAR=0.0
Pod documented
1228 12 my ($self, @code) = @_;
1229  
1230 12 ▶ push @{$self->on_eval}, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
1231 18 my ($source, $value) = @_;
1232 18 ▶ if (CORE::defined($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) { } 16 2 18
1233 16 return $source->pass($value, {
1234 from => 'value',
1235 });
1236 }
1237 else {
1238 2 return $source->fail($value, {
1239 from => 'value',
1240 with => 'error_on_defined',
1241 });
1242 }
1243 16 ▶ }, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
1244 16 my ($source, $value) = @_;
1245 16 ▶ if (!CORE::ref($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not ref $value) { } 9 7 16
1246 9 return $source->pass($value, {
1247 from => 'value',
1248 });
1249 }
1250 else {
1251 7 return $source->fail($value, {
1252 from => 'value',
1253 with => 'error_on_value',
1254 });
1255 }
1256 12 }, @code;
1257  
1258 12 return $self;
1259 }
1260  
1261 42 ▶sub within {
Subroutine within: called CC=11 SCAR=24.1
Pod documented
1262 42 my ($self, $type, @next) = @_;
1263  
1264 42 ▶ if (!$type) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($type) 0 42 42
1265 0 return $self;
1266 }
1267  
1268 42 my $where = $self->new;
1269  
1270 42 ▶ if (lc($type) eq 'hash' || lc($type) eq 'hashref') {
Branch: 2 branches
BranchTrueFalseTotal
if (lc $type eq 'hash' or lc $type eq 'hashref') { } 17 25 42
elsif (lc $type eq 'array' or lc $type eq 'arrayref') { } 21 4 25
Condition66%2/3
lc $type eq "hash" or lc $type eq "hashref"
l!l&&r!l&&!r
01725
MC/DC50%1/2
lc $type eq "hash" or lc $type eq "hashref"
lc $type eq "hash" lc $type eq "hashref"
Truth table66%2/3
A or B
A= lc $type eq "hash"B= lc $type eq "hashref"
ABresult
1X1
011
000
1271 17 ▶ push @{$self->on_eval}, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
1272 16 my ($source, $value) = @_;
1273 16 ▶ if (CORE::defined($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) { } 15 1 16
1274 15 return $source->pass($value, {
1275 from => 'within',
1276 });
1277 }
1278 else {
1279 1 return $source->fail($value, {
1280 from => 'within',
1281 with => 'error_on_defined',
1282 });
1283 }
1284 15 ▶ }, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
1285 15 my ($source, $value) = @_;
1286 15 ▶ if (UNIVERSAL::isa($value, 'HASH')) {
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::isa($value, 'HASH')) { } 14 1 15
1287 14 return $source->pass($value, {
1288 from => 'within',
1289 });
1290 }
1291 else {
1292 1 return $source->fail($value, {
1293 from => 'within',
1294 with => 'error_on_hashref',
1295 });
1296 }
1297 14 ▶ }, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
1298 14 my ($source, $value) = @_;
1299 14 ▶ if ((CORE::keys %{$value}) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (keys %{$value;} > 0) { } 12 2 14
1300 12 return $source->pass($value, {
1301 from => 'within',
1302 });
1303 }
1304 else {
1305 2 return $source->fail($value, {
1306 from => 'within',
1307 with => 'error_on_hashref_empty',
1308 });
1309 }
1310 12 ▶ }, sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
1311 12 my ($source, $value) = @_;
1312 12 my $result = true;
1313 12 for my $key (CORE::keys %{$value}) {
1314 30 my $check = $where->branch($key);
1315 30 $check->on_eval($where->on_eval);
1316 30 ▶ if (!$check->eval($value->{$key})) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($check->eval($value->{$key})) 3 27 30
1317 $result = $source->fail($value, {
1318 branch => $check->{'$branch'},
1319 3 %{$check->{'$result'}},
1320 from => 'within',
1321 });
1322 3 last;
1323 }
1324 }
1325 12 ▶ if (!$result) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $result) { } 3 9 12
1326 3 return $result;
1327 }
1328 else {
1329 9 return $self->pass($value, {
1330 from => 'within',
1331 });
1332 }
1333 17 };
1334 }
1335 ▶ elsif (lc($type) eq 'array' || lc($type) eq 'arrayref') {
Condition66%2/3
lc $type eq "array" or lc $type eq "arrayref"
l!l&&r!l&&!r
0214
MC/DC50%1/2
lc $type eq "array" or lc $type eq "arrayref"
lc $type eq "array" lc $type eq "arrayref"
Truth table66%2/3
A or B
A= lc $type eq "array"B= lc $type eq "arrayref"
ABresult
1X1
011
000
1336 21 ▶ push @{$self->on_eval}, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
1337 35 my ($source, $value) = @_;
1338 35 ▶ if (CORE::defined($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) { } 33 2 35
1339 33 return $source->pass($value, {
1340 from => 'within',
1341 });
1342 }
1343 else {
1344 2 return $source->fail($value, {
1345 from => 'within',
1346 with => 'error_on_defined',
1347 });
1348 }
1349 33 ▶ }, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
1350 33 my ($source, $value) = @_;
1351 33 ▶ if (UNIVERSAL::isa($value, 'ARRAY')) {
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::isa($value, 'ARRAY')) { } 24 9 33
1352 24 return $source->pass($value, {
1353 from => 'within',
1354 });
1355 }
1356 else {
1357 9 return $source->fail($value, {
1358 from => 'within',
1359 with => 'error_on_arrayref',
1360 });
1361 }
1362 24 ▶ }, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
1363 24 my ($source, $value) = @_;
1364 24 ▶ if (@{$value} > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$value;} > 0) { } 19 5 24
1365 19 return $source->pass($value, {
1366 from => 'within',
1367 });
1368 }
1369 else {
1370 5 return $source->fail($value, {
1371 from => 'within',
1372 with => 'error_on_arrayref_count',
1373 });
1374 }
1375 19 ▶ }, sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
1376 19 my ($source, $value) = @_;
1377 19 my $result = true;
1378 19 my $key = 0;
1379 19 for my $item (@{$value}) {
1380 67 my $check = $where->branch($key++);
1381 67 $check->on_eval($where->on_eval);
1382 67 ▶ if (!$check->eval($item)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($check->eval($item)) 7 60 67
1383 $result = $source->fail($value, {
1384 branch => $check->{'$branch'},
1385 7 %{$check->{'$result'}},
1386 from => 'within',
1387 });
1388 7 last;
1389 }
1390 }
1391 19 ▶ if (!$result) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $result) { } 7 12 19
1392 7 return $result;
1393 }
1394 else {
1395 12 return $self->pass($value, {
1396 from => 'within',
1397 });
1398 }
1399 21 };
1400 }
1401 else {
1402 4 require Venus::Meta;
1403 4 require Venus::Space;
1404 4 my $meta = Venus::Meta->new(
1405 name => Venus::Space->new($type)->do('tryload')->package,
1406 );
1407 4 ▶ if ($type && !ref $type && $meta->role('Venus::Role::Mappable')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type and not ref $type and $meta->role('Venus::Role::Mappable')) { } 3 1 4
Condition50%3/6
$type and not ref $type and $meta->role("Venus::Role::Mappable")
!ll&&!rl&&r
013
$type and not ref $type
!ll&&!rl&&r
004
MC/DC33%1/3
$type and not ref $type and $meta->role("Venus::Role::Mappable")
$type not ref $type $meta->role("Venus::Role::Mappable")
Truth table50%2/4
A and not(B) and C
A= $typeB= not ref $typeC= $meta->role("Venus::Role::Mappable")
ABCresult
0XX0
10X0
1100
1111
1408 3 ▶ push @{$self->on_eval}, sub {
Subroutine __ANON__: called CC=2 SCAR=7.4
1409 3 my ($source, $value) = @_;
1410 3 ▶ if (CORE::defined($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) { } 3 0 3
1411 3 return $source->pass($value, {
1412 from => 'within',
1413 });
1414 }
1415 else {
1416 0 return $source->fail($value, {
1417 from => 'within',
1418 with => 'error_on_defined',
1419 });
1420 }
1421 3 ▶ }, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
1422 3 my ($source, $value) = @_;
1423 3 ▶ if (UNIVERSAL::isa($value, $type)) {
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::isa($value, $type)) { } 2 1 3
1424 2 return $source->pass($value, {
1425 from => 'within',
1426 });
1427 }
1428 else {
1429 1 return $source->fail($value, {
1430 from => 'within',
1431 expected => $type,
1432 received => $source->what($value),
1433 with => 'error_on_mappable_isa',
1434 });
1435 }
1436 2 ▶ }, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
1437 2 my ($source, $value) = @_;
1438 2 ▶ if ($value->count) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->count) { } 1 1 2
1439 1 return $source->pass($value, {
1440 from => 'within',
1441 });
1442 }
1443 else {
1444 1 return $source->fail($value, {
1445 from => 'within',
1446 with => 'error_on_mappable_empty',
1447 });
1448 }
1449 1 ▶ }, sub {
Subroutine __ANON__: called CC=4 SCAR=15.5
1450 1 my ($source, $value) = @_;
1451 1 my $result = true;
1452 1 for my $key (@{$value->keys}) {
1453 1 my $check = $where->branch($key);
1454 1 $check->on_eval($where->on_eval);
1455 1 ▶ if (!$check->eval($value->get($key))) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($check->eval($value->get($key))) 0 1 1
1456 $result = $source->fail($value, {
1457 branch => $check->{'$branch'},
1458 0 %{$check->{'$result'}},
1459 from => 'within',
1460 });
1461 0 last;
1462 }
1463 }
1464 1 ▶ if (!$result) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $result) { } 0 1 1
1465 0 return $result;
1466 }
1467 else {
1468 1 return $self->pass($value, {
1469 from => 'within',
1470 });
1471 }
1472 3 };
1473 }
1474 else {
1475 1 return $self->error({
1476 throw => 'error_on_within',
1477 type => $type,
1478 args => [@next]
1479 });
1480 }
1481 }
1482  
1483 41 ▶ $where->accept(map +(ref($_) ? @$_ : $_), $next[0]) if @next;
Branch: 2 branches
BranchTrueFalseTotal
if @next 41 0 41
ref $_ ? : 8 33 41
1484  
1485 41 return $where;
1486 }
1487  
1488 19 ▶sub yesno {
Subroutine yesno: called CC=1 SCAR=0.0
Pod documented
1489 19 my ($self, @code) = @_;
1490  
1491 19 ▶ push @{$self->on_eval}, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
1492 27 my ($source, $value) = @_;
1493 27 ▶ if (CORE::defined($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) { } 24 3 27
1494 24 return $source->pass($value, {
1495 from => 'yesno',
1496 });
1497 }
1498 else {
1499 3 return $source->fail($value, {
1500 from => 'yesno',
1501 with => 'error_on_defined',
1502 });
1503 }
1504 24 ▶ }, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
1505 24 my ($source, $value) = @_;
1506 24 ▶ if ($value =~ /^(?:1|y(?:es)?|0|n(?:o)?)$/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /^(?:1|y(?:es)?|0|n(?:o)?)$/iu) { } 18 6 24
1507 18 return $source->pass($value, {
1508 from => 'yesno',
1509 });
1510 }
1511 else {
1512 6 return $source->fail($value, {
1513 from => 'yesno',
1514 with => 'error_on_yesno',
1515 });
1516 }
1517 19 }, @code;
1518  
1519 19 return $self;
1520 }
1521  
1522 # ERRORS
1523  
1524 8 ▶sub error_on_arrayref {
Subroutine error_on_arrayref: called CC=1 SCAR=0.0
Pod undocumented
1525 8 my ($self, $data) = @_;
1526  
1527 8 my $error = $self->error->sysinfo;
1528  
1529 8 my $message = join ', ',
1530 'Failed checking {{from}}',
1531 'value provided is not an arrayref or arrayref derived',
1532 'at {{at}}';
1533  
1534 8 $error->name('on.arrayref');
1535 8 $error->message($message);
1536 8 $error->offset(1);
1537 8 $error->stash($data);
1538 8 $error->reset;
1539  
1540 8 return $error;
1541 }
1542  
1543 4 ▶sub error_on_arrayref_count {
Subroutine error_on_arrayref_count: called CC=1 SCAR=0.0
Pod undocumented
1544 4 my ($self, $data) = @_;
1545  
1546 4 my $error = $self->error->sysinfo;
1547  
1548 4 my $message = join ', ',
1549 'Failed checking {{from}}',
1550 'incorrect item count in arrayref or arrayref derived object',
1551 'at {{at}}';
1552  
1553 4 $error->name('on.arrayref.count');
1554 4 $error->message($message);
1555 4 $error->offset(1);
1556 4 $error->stash($data);
1557 4 $error->reset;
1558  
1559 4 return $error;
1560 }
1561  
1562 129 ▶sub error_on_coded {
Subroutine error_on_coded: called CC=1 SCAR=0.0
Pod undocumented
1563 129 my ($self, $data) = @_;
1564  
1565 129 my $error = $self->error->sysinfo;
1566  
1567 129 my $message = join ', ',
1568 'Failed checking {{from}}',
1569 'expected {{expected}}',
1570 'received {{received}}',
1571 'at {{at}}';
1572  
1573 129 $error->name('on.coded');
1574 129 $error->message($message);
1575 129 $error->offset(1);
1576 129 $error->stash($data);
1577 129 $error->reset;
1578  
1579 129 return $error;
1580 }
1581  
1582 3 ▶sub error_on_consumes {
Subroutine error_on_consumes: called CC=1 SCAR=0.0
Pod undocumented
1583 3 my ($self, $data) = @_;
1584  
1585 3 my $error = $self->error->sysinfo;
1586  
1587 3 my $message = join ', ',
1588 'Failed checking {{from}}',
1589 'object does not consume the role "{{role}}"',
1590 'at {{at}}';
1591  
1592 3 $error->name('on.consumes');
1593 3 $error->message($message);
1594 3 $error->offset(1);
1595 3 $error->stash($data);
1596 3 $error->reset;
1597  
1598 3 return $error;
1599 }
1600  
1601 9 ▶sub error_on_defined {
Subroutine error_on_defined: called CC=1 SCAR=0.0
Pod undocumented
1602 9 my ($self, $data) = @_;
1603  
1604 9 my $error = $self->error->sysinfo;
1605  
1606 9 my $message = join ', ',
1607 'Failed checking {{from}}',
1608 'value provided is undefined',
1609 'at {{at}}';
1610  
1611 9 $error->name('on.defined');
1612 9 $error->message($message);
1613 9 $error->offset(1);
1614 9 $error->stash($data);
1615 9 $error->reset;
1616  
1617 9 return $error;
1618 }
1619  
1620 2 ▶sub error_on_dirhandle {
Subroutine error_on_dirhandle: called CC=1 SCAR=0.0
Pod undocumented
1621 2 my ($self, $data) = @_;
1622  
1623 2 my $error = $self->error->sysinfo;
1624  
1625 2 my $message = join ', ',
1626 'Failed checking {{from}}',
1627 'value provided is not a dirhandle (or is not open)',
1628 'at {{at}}';
1629  
1630 2 $error->name('on.dirhandle');
1631 2 $error->message($message);
1632 2 $error->offset(1);
1633 2 $error->stash($data);
1634 2 $error->reset;
1635  
1636 2 return $error;
1637 }
1638  
1639 7 ▶sub error_on_either {
Subroutine error_on_either: called CC=1 SCAR=0.0
Pod undocumented
1640 7 my ($self, $data) = @_;
1641  
1642 7 my $error = $self->error->sysinfo;
1643  
1644 my $message = join "\n\n",
1645 'Failed checking either-or condition:',
1646 7 @{$data->{errors}};
1647  
1648 7 $error->name('on.either');
1649 7 $error->message($message);
1650 7 $error->offset(1);
1651 7 $error->stash($data);
1652 7 $error->reset;
1653  
1654 7 return $error;
1655 }
1656  
1657 2 ▶sub error_on_enum {
Subroutine error_on_enum: called CC=1 SCAR=0.0
Pod undocumented
1658 2 my ($self, $data) = @_;
1659  
1660 2 my $error = $self->error->sysinfo;
1661  
1662 2 my $message = join ', ',
1663 'Failed checking {{from}}',
1664 'received {{data}}',
1665 'valid options are {{options}}',
1666 'at {{at}}';
1667  
1668 2 $error->stash(options => (join ', ', @{$data->{enum}}));
1669 2 $error->name('on.enum');
1670 2 $error->message($message);
1671 2 $error->offset(1);
1672 2 $error->stash($data);
1673 2 $error->reset;
1674  
1675 2 return $error;
1676 }
1677  
1678 2 ▶sub error_on_filehandle {
Subroutine error_on_filehandle: called CC=1 SCAR=0.0
Pod undocumented
1679 2 my ($self, $data) = @_;
1680  
1681 2 my $error = $self->error->sysinfo;
1682  
1683 2 my $message = join ', ',
1684 'Failed checking {{from}}',
1685 'value provided is not a filehandle (or is not open)',
1686 'at {{at}}';
1687  
1688 2 $error->name('on.filehandle');
1689 2 $error->message($message);
1690 2 $error->offset(1);
1691 2 $error->stash($data);
1692 2 $error->reset;
1693  
1694 2 return $error;
1695 }
1696  
1697 3 ▶sub error_on_hashref {
Subroutine error_on_hashref: called CC=1 SCAR=0.0
Pod undocumented
1698 3 my ($self, $data) = @_;
1699  
1700 3 my $error = $self->error->sysinfo;
1701  
1702 3 my $message = join ', ',
1703 'Failed checking {{from}}',
1704 'value provided is not a hashref or hashref derived',
1705 'at {{at}}';
1706  
1707 3 $error->name('on.hashref');
1708 3 $error->message($message);
1709 3 $error->offset(1);
1710 3 $error->stash($data);
1711 3 $error->reset;
1712  
1713 3 return $error;
1714 }
1715  
1716 2 ▶sub error_on_hashref_empty {
Subroutine error_on_hashref_empty: called CC=1 SCAR=0.0
Pod undocumented
1717 2 my ($self, $data) = @_;
1718  
1719 2 my $error = $self->error->sysinfo;
1720  
1721 2 my $message = join ', ',
1722 'Failed checking {{from}}',
1723 'no items found in hashref or hashref derived object',
1724 'at {{at}}';
1725  
1726 2 $error->name('on.hashref.empty');
1727 2 $error->message($message);
1728 2 $error->offset(1);
1729 2 $error->stash($data);
1730 2 $error->reset;
1731  
1732 2 return $error;
1733 }
1734  
1735 2 ▶sub error_on_includes {
Subroutine error_on_includes: called CC=1 SCAR=0.0
Pod undocumented
1736 2 my ($self, $data) = @_;
1737  
1738 2 my $error = $self->error->sysinfo;
1739  
1740 my $message = join "\n\n",
1741 'Failed checking union-includes condition:',
1742 2 @{$data->{errors}};
1743  
1744 2 $error->name('on.includes');
1745 2 $error->message($message);
1746 2 $error->offset(1);
1747 2 $error->stash($data);
1748 2 $error->reset;
1749  
1750 2 return $error;
1751 }
1752  
1753 2 ▶sub error_on_identity {
Subroutine error_on_identity: called CC=1 SCAR=0.0
Pod undocumented
1754 2 my ($self, $data) = @_;
1755  
1756 2 my $error = $self->error->sysinfo;
1757  
1758 2 my $message = join ', ',
1759 'Failed checking {{from}}',
1760 'object is not a {{name}} or derived object',
1761 'at {{at}}';
1762  
1763 2 $error->name('on.identity');
1764 2 $error->message($message);
1765 2 $error->offset(1);
1766 2 $error->stash($data);
1767 2 $error->reset;
1768  
1769 2 return $error;
1770 }
1771  
1772 2 ▶sub error_on_inherits {
Subroutine error_on_inherits: called CC=1 SCAR=0.0
Pod undocumented
1773 2 my ($self, $data) = @_;
1774  
1775 2 my $error = $self->error->sysinfo;
1776  
1777 2 my $message = join ', ',
1778 'Failed checking {{from}}',
1779 'object is not a {{name}} derived object',
1780 'at {{at}}';
1781  
1782 2 $error->name('on.inherits');
1783 2 $error->message($message);
1784 2 $error->offset(1);
1785 2 $error->stash($data);
1786 2 $error->reset;
1787  
1788 2 return $error;
1789 }
1790  
1791 0 ▶sub error_on_isa {
Subroutine error_on_isa: not called CC=1 SCAR=6.9
Pod undocumented
1792 0 my ($self, $data) = @_;
1793  
1794 0 my $error = $self->error->sysinfo;
1795  
1796 0 my $message = join ', ',
1797 'Failed checking {{from}}',
1798 'expected instance (or subclass) of {{expected}}',
1799 'received {{received}}',
1800 'at {{at}}';
1801  
1802 0 $error->name('on.isa');
1803 0 $error->message($message);
1804 0 $error->offset(1);
1805 0 $error->stash($data);
1806 0 $error->reset;
1807  
1808 0 return $error;
1809 }
1810  
1811 1 ▶sub error_on_mappable_isa {
Subroutine error_on_mappable_isa: called CC=1 SCAR=0.0
Pod undocumented
1812 1 my ($self, $data) = @_;
1813  
1814 1 my $error = $self->error->sysinfo;
1815  
1816 1 my $message = join ', ',
1817 'Failed checking {{from}}',
1818 'expected instance (or subclass) of {{expected}}',
1819 'received {{received}}',
1820 'at {{at}}';
1821  
1822 1 $error->name('on.mappable.isa');
1823 1 $error->message($message);
1824 1 $error->offset(1);
1825 1 $error->stash($data);
1826 1 $error->reset;
1827  
1828 1 return $error;
1829 }
1830  
1831 1 ▶sub error_on_mappable_empty {
Subroutine error_on_mappable_empty: called CC=1 SCAR=0.0
Pod undocumented
1832 1 my ($self, $data) = @_;
1833  
1834 1 my $error = $self->error->sysinfo;
1835  
1836 1 my $message = join ', ',
1837 'Failed checking {{from}}',
1838 'no items found in mappable object',
1839 'at {{at}}';
1840  
1841 1 $error->name('on.mappable.empty');
1842 1 $error->message($message);
1843 1 $error->offset(1);
1844 1 $error->stash($data);
1845 1 $error->reset;
1846  
1847 1 return $error;
1848 }
1849  
1850 4 ▶sub error_on_missing {
Subroutine error_on_missing: called CC=1 SCAR=0.0
Pod undocumented
1851 4 my ($self, $data) = @_;
1852  
1853 4 my $error = $self->error->sysinfo;
1854  
1855 4 my $message = join ', ',
1856 'Failed checking {{from}}',
1857 '"{{name}}" is missing',
1858 'at {{at}}';
1859  
1860 4 $error->name('on.missing');
1861 4 $error->message($message);
1862 4 $error->offset(1);
1863 4 $error->stash($data);
1864 4 $error->reset;
1865  
1866 4 return $error;
1867 }
1868  
1869 2 ▶sub error_on_package {
Subroutine error_on_package: called CC=1 SCAR=0.0
Pod undocumented
1870 2 my ($self, $data) = @_;
1871  
1872 2 my $error = $self->error->sysinfo;
1873  
1874 2 my $message = join ', ',
1875 'Failed checking {{from}}',
1876 '"{{data}}" is not a valid package name',
1877 'at {{at}}';
1878  
1879 2 $error->name('on.package');
1880 2 $error->message($message);
1881 2 $error->offset(1);
1882 2 $error->stash($data);
1883 2 $error->reset;
1884  
1885 2 return $error;
1886 }
1887  
1888 2 ▶sub error_on_package_loaded {
Subroutine error_on_package_loaded: called CC=1 SCAR=0.0
Pod undocumented
1889 2 my ($self, $data) = @_;
1890  
1891 2 my $error = $self->error->sysinfo;
1892  
1893 2 my $message = join ', ',
1894 'Failed checking {{from}}',
1895 '"{{data}}" is not loaded',
1896 'at {{at}}';
1897  
1898 2 $error->name('on.package.loaded');
1899 2 $error->message($message);
1900 2 $error->offset(1);
1901 2 $error->stash($data);
1902 2 $error->reset;
1903  
1904 2 return $error;
1905 }
1906  
1907 3 ▶sub error_on_pairs {
Subroutine error_on_pairs: called CC=1 SCAR=0.0
Pod undocumented
1908 3 my ($self, $data) = @_;
1909  
1910 3 my $error = $self->error->sysinfo;
1911  
1912 3 my $message = join ', ',
1913 'Failed checking {{from}}',
1914 'imblanced key/value pairs provided',
1915 'at {{at}}';
1916  
1917 3 $error->name('on.pairs');
1918 3 $error->message($message);
1919 3 $error->offset(1);
1920 3 $error->stash($data);
1921 3 $error->reset;
1922  
1923 3 return $error;
1924 }
1925  
1926 2 ▶sub error_on_reference {
Subroutine error_on_reference: called CC=1 SCAR=0.0
Pod undocumented
1927 2 my ($self, $data) = @_;
1928  
1929 2 my $error = $self->error->sysinfo;
1930  
1931 2 my $message = join ', ',
1932 'Failed checking {{from}}',
1933 'value provided is not a reference',
1934 'at {{at}}';
1935  
1936 2 $error->name('on.reference');
1937 2 $error->message($message);
1938 2 $error->offset(1);
1939 2 $error->stash($data);
1940 2 $error->reset;
1941  
1942 2 return $error;
1943 }
1944  
1945 2 ▶sub error_on_typeglob {
Subroutine error_on_typeglob: called CC=1 SCAR=0.0
Pod undocumented
1946 2 my ($self, $data) = @_;
1947  
1948 2 my $error = $self->error->sysinfo;
1949  
1950 2 my $message = join ', ',
1951 'Failed checking {{from}}',
1952 'value provided is not a typeglob',
1953 'at {{at}}';
1954  
1955 2 $error->name('on.typeglob');
1956 2 $error->message($message);
1957 2 $error->offset(1);
1958 2 $error->stash($data);
1959 2 $error->reset;
1960  
1961 2 return $error;
1962 }
1963  
1964 2 ▶sub error_on_value {
Subroutine error_on_value: called CC=1 SCAR=0.0
Pod undocumented
1965 2 my ($self, $data) = @_;
1966  
1967 2 my $error = $self->error->sysinfo;
1968  
1969 2 my $message = join ', ',
1970 'Failed checking {{from}}',
1971 'value provided is a reference',
1972 'at {{at}}';
1973  
1974 2 $error->name('on.value');
1975 2 $error->message($message);
1976 2 $error->offset(1);
1977 2 $error->stash($data);
1978 2 $error->reset;
1979  
1980 2 return $error;
1981 }
1982  
1983 1 ▶sub error_on_within {
Subroutine error_on_within: called CC=1 SCAR=0.0
Pod undocumented
1984 1 my ($self, $data) = @_;
1985  
1986 1 my $error = $self->error->sysinfo;
1987  
1988 1 my $message = 'Invalid type "{{type}}" provided to the "within" method';
1989  
1990 1 $error->name('on.within');
1991 1 $error->message($message);
1992 1 $error->offset(1);
1993 1 $error->stash($data);
1994 1 $error->reset;
1995  
1996 1 return $error;
1997 }
1998  
1999 0 ▶sub error_on_unknown {
Subroutine error_on_unknown: not called CC=1 SCAR=6.9
Pod undocumented
2000 0 my ($self, $data) = @_;
2001  
2002 0 my $error = $self->error->sysinfo;
2003  
2004 0 my $message = 'Failed performing check for unknown reason';
2005  
2006 0 $error->name('on.unknown');
2007 0 $error->message($message);
2008 0 $error->offset(1);
2009 0 $error->stash($data);
2010 0 $error->reset;
2011  
2012 0 return $error;
2013 }
2014  
2015 2 ▶sub error_on_yesno {
Subroutine error_on_yesno: called CC=1 SCAR=0.0
Pod undocumented
2016 2 my ($self, $data) = @_;
2017  
2018 2 my $error = $self->error->sysinfo;
2019  
2020 2 my $message = join ', ',
2021 'Failed checking {{from}}',
2022 'value provided is not a recognized "yes" or "no" value',
2023 'at {{at}}';
2024  
2025 2 $error->name('on.yesno');
2026 2 $error->message($message);
2027 2 $error->offset(1);
2028 2 $error->stash($data);
2029 2 $error->reset;
2030  
2031 2 return $error;
2032 }
2033  
2034 25 1;
2035  
2036  
2037  
2038 =head1 NAME
2039  
2040 Venus::Check - Check Class
2041  
2042 =cut
2043  
2044 =head1 ABSTRACT
2045  
2046 Check Class for Perl 5
2047  
2048 =cut
2049  
2050 =head1 SYNOPSIS
2051  
2052 package main;
2053  
2054 use Venus::Check;
2055  
2056 my $check = Venus::Check->new;
2057  
2058 # $check->float;
2059  
2060 # my $result = $check->result(rand);
2061  
2062 # 0.1234567890
2063  
2064 =cut
2065  
2066 =head1 DESCRIPTION
2067  
2068 This package provides a mechanism for performing runtime dynamic type checking
2069 on data.
2070  
2071 =cut
2072  
2073 =head1 ATTRIBUTES
2074  
2075 This package has the following attributes:
2076  
2077 =cut
2078  
2079 =head2 on_eval
2080  
2081 on_eval(within[arrayref, coderef] $data) (within[arrayref, coderef])
2082  
2083 The on_eval attribute is read-write, accepts C<(ArrayRef[CodeRef])> values, and
2084 is optional.
2085  
2086 I<Since C<3.55>>
2087  
2088 =over 4
2089  
2090 =item on_eval example 1
2091  
2092 # given: synopsis
2093  
2094 package main;
2095  
2096 my $set_on_eval = $check->on_eval([sub{1}]);
2097  
2098 # [sub{1}]
2099  
2100 =back
2101  
2102 =over 4
2103  
2104 =item on_eval example 2
2105  
2106 # given: synopsis
2107  
2108 # given: example-1 on_eval
2109  
2110 package main;
2111  
2112 my $get_on_eval = $check->on_eval;
2113  
2114 # [sub{1}]
2115  
2116 =back
2117  
2118 =cut
2119  
2120 =head1 INHERITS
2121  
2122 This package inherits behaviors from:
2123  
2124 L<Venus::Kind::Utility>
2125  
2126 =cut
2127  
2128 =head1 INTEGRATES
2129  
2130 This package integrates behaviors from:
2131  
2132 L<Venus::Role::Buildable>
2133  
2134 =cut
2135  
2136 =head1 METHODS
2137  
2138 This package provides the following methods:
2139  
2140 =cut
2141  
2142 =head2 accept
2143  
2144 accept(string $name, string | within[arrayref, string] @args) (Venus::Check)
2145  
2146 The accept method configures the object to accept the conditions or identity
2147 provided and returns the invocant. This method dispatches to the method(s)
2148 specified, or to the L</identity> method otherwise.
2149  
2150 I<Since C<3.55>>
2151  
2152 =over 4
2153  
2154 =item accept example 1
2155  
2156 # given: synopsis
2157  
2158 package main;
2159  
2160 $check = $check->accept('string');
2161  
2162 # bless(..., 'Venus::Check')
2163  
2164 # my $result = $check->eval('okay');
2165  
2166 # true
2167  
2168 =back
2169  
2170 =over 4
2171  
2172 =item accept example 2
2173  
2174 # given: synopsis
2175  
2176 package main;
2177  
2178 $check = $check->accept('string');
2179  
2180 # bless(..., 'Venus::Check')
2181  
2182 # my $result = $check->eval(12345);
2183  
2184 # false
2185  
2186 =back
2187  
2188 =over 4
2189  
2190 =item accept example 3
2191  
2192 # given: synopsis
2193  
2194 package main;
2195  
2196 $check = $check->accept('string');
2197  
2198 # bless(..., 'Venus::Check')
2199  
2200 # my $result = $check->result('okay');
2201  
2202 # 'okay'
2203  
2204 =back
2205  
2206 =over 4
2207  
2208 =item accept example 4
2209  
2210 # given: synopsis
2211  
2212 package main;
2213  
2214 $check = $check->accept('string');
2215  
2216 # bless(..., 'Venus::Check')
2217  
2218 # my $result = $check->result(12345);
2219  
2220 # Exception! (isa Venus::Check::Error) (see error_on_coded)
2221  
2222 =back
2223  
2224 =cut
2225  
2226 =head2 any
2227  
2228 any() (Venus::Check)
2229  
2230 The any method configures the object to accept any value and returns the
2231 invocant.
2232  
2233 I<Since C<3.55>>
2234  
2235 =over 4
2236  
2237 =item any example 1
2238  
2239 # given: synopsis
2240  
2241 package main;
2242  
2243 $check = $check->any;
2244  
2245 # bless(..., 'Venus::Check')
2246  
2247 # my $result = $check->eval(1);
2248  
2249 # true
2250  
2251 =back
2252  
2253 =over 4
2254  
2255 =item any example 2
2256  
2257 # given: synopsis
2258  
2259 package main;
2260  
2261 $check = $check->any;
2262  
2263 # bless(..., 'Venus::Check')
2264  
2265 # my $result = $check->eval(bless{});
2266  
2267 # true
2268  
2269 =back
2270  
2271 =cut
2272  
2273 =head2 array
2274  
2275 array(coderef @code) (Venus::Check)
2276  
2277 The array method configures the object to accept array references and returns
2278 the invocant.
2279  
2280 I<Since C<3.55>>
2281  
2282 =over 4
2283  
2284 =item array example 1
2285  
2286 # given: synopsis
2287  
2288 package main;
2289  
2290 $check = $check->array;
2291  
2292 # bless(..., 'Venus::Check')
2293  
2294 # my $result = $check->eval([]);
2295  
2296 # true
2297  
2298 =back
2299  
2300 =over 4
2301  
2302 =item array example 2
2303  
2304 # given: synopsis
2305  
2306 package main;
2307  
2308 $check = $check->array;
2309  
2310 # bless(..., 'Venus::Check')
2311  
2312 # my $result = $check->eval({});
2313  
2314 # false
2315  
2316 =back
2317  
2318 =over 4
2319  
2320 =item array example 3
2321  
2322 # given: synopsis
2323  
2324 package main;
2325  
2326 $check = $check->array;
2327  
2328 # bless(..., 'Venus::Check')
2329  
2330 # my $result = $check->result([1..4]);
2331  
2332 # [1..4]
2333  
2334 =back
2335  
2336 =over 4
2337  
2338 =item array example 4
2339  
2340 # given: synopsis
2341  
2342 package main;
2343  
2344 $check = $check->array;
2345  
2346 # bless(..., 'Venus::Check')
2347  
2348 # my $result = $check->result({1..4});
2349  
2350 # Exception! (isa Venus::Check::Error) (see error_on_coded)
2351  
2352 =back
2353  
2354 =cut
2355  
2356 =head2 arrayref
2357  
2358 arrayref(coderef @code) (Venus::Check)
2359  
2360 The arrayref method configures the object to accept array references and returns
2361 the invocant.
2362  
2363 I<Since C<3.55>>
2364  
2365 =over 4
2366  
2367 =item arrayref example 1
2368  
2369 # given: synopsis
2370  
2371 package main;
2372  
2373 $check = $check->arrayref;
2374  
2375 # bless(..., 'Venus::Check')
2376  
2377 # my $result = $check->eval([]);
2378  
2379 # true
2380  
2381 =back
2382  
2383 =over 4
2384  
2385 =item arrayref example 2
2386  
2387 # given: synopsis
2388  
2389 package main;
2390  
2391 $check = $check->arrayref;
2392  
2393 # bless(..., 'Venus::Check')
2394  
2395 # my $result = $check->eval({});
2396  
2397 # false
2398  
2399 =back
2400  
2401 =over 4
2402  
2403 =item arrayref example 3
2404  
2405 # given: synopsis
2406  
2407 package main;
2408  
2409 $check = $check->arrayref;
2410  
2411 # bless(..., 'Venus::Check')
2412  
2413 # my $result = $check->result([1..4]);
2414  
2415 # [1..4]
2416  
2417 =back
2418  
2419 =over 4
2420  
2421 =item arrayref example 4
2422  
2423 # given: synopsis
2424  
2425 package main;
2426  
2427 $check = $check->arrayref;
2428  
2429 # bless(..., 'Venus::Check')
2430  
2431 # my $result = $check->result({1..4});
2432  
2433 # Exception! (isa Venus::Check::Error) (see error_on_coded)
2434  
2435 =back
2436  
2437 =cut
2438  
2439 =head2 attributes
2440  
2441 attributes(string | within[arrayref, string] @args) (Venus::Check)
2442  
2443 The attributes method configures the object to accept objects containing
2444 attributes whose values' match the attribute names and types specified, and
2445 returns the invocant.
2446  
2447 I<Since C<3.55>>
2448  
2449 =over 4
2450  
2451 =item attributes example 1
2452  
2453 # given: synopsis
2454  
2455 package Example;
2456  
2457 use Venus::Class 'attr';
2458  
2459 attr 'name';
2460  
2461 package main;
2462  
2463 $check = $check->attributes('name', 'string');
2464  
2465 # bless(..., 'Venus::Check')
2466  
2467 # my $result = $check->eval(Example->new(name => 'test'));
2468  
2469 # true
2470  
2471 =back
2472  
2473 =over 4
2474  
2475 =item attributes example 2
2476  
2477 # given: synopsis
2478  
2479 package Example;
2480  
2481 use Venus::Class 'attr';
2482  
2483 attr 'name';
2484  
2485 package main;
2486  
2487 $check = $check->attributes('name', 'string');
2488  
2489 # bless(..., 'Venus::Check')
2490  
2491 # my $result = $check->eval(Example->new);
2492  
2493 # false
2494  
2495 =back
2496  
2497 =over 4
2498  
2499 =item attributes example 3
2500  
2501 # given: synopsis
2502  
2503 package Example;
2504  
2505 use Venus::Class 'attr';
2506  
2507 attr 'name';
2508  
2509 package main;
2510  
2511 $check = $check->attributes('name', 'string');
2512  
2513 # bless(..., 'Venus::Check')
2514  
2515 # my $result = $check->result(Example->new(name => 'test'));
2516  
2517 # bless(..., 'Example')
2518  
2519 =back
2520  
2521 =over 4
2522  
2523 =item attributes example 4
2524  
2525 # given: synopsis
2526  
2527 package Example;
2528  
2529 use Venus::Class 'attr';
2530  
2531 attr 'name';
2532  
2533 package main;
2534  
2535 $check = $check->attributes('name', 'string');
2536  
2537 # bless(..., 'Venus::Check')
2538  
2539 # my $result = $check->result({});
2540  
2541 # Exception! (isa Venus::Check::Error) (see error_on_coded)
2542  
2543 =back
2544  
2545 =over 4
2546  
2547 =item attributes example 5
2548  
2549 # given: synopsis
2550  
2551 package Example;
2552  
2553 use Venus::Class 'attr';
2554  
2555 attr 'name';
2556  
2557 package main;
2558  
2559 $check = $check->attributes('name', 'string', 'age');
2560  
2561 # bless(..., 'Venus::Check')
2562  
2563 # my $result = $check->result(Example->new);
2564  
2565 # Exception! (isa Venus::Check::Error) (see error_on_pairs)
2566  
2567 =back
2568  
2569 =over 4
2570  
2571 =item attributes example 6
2572  
2573 # given: synopsis
2574  
2575 package Example;
2576  
2577 use Venus::Class;
2578  
2579 package main;
2580  
2581 $check = $check->attributes('name', 'string');
2582  
2583 # bless(..., 'Venus::Check')
2584  
2585 # my $result = $check->result(Example->new);
2586  
2587 # Exception! (isa Venus::Check::Error) (see error_on_missing)
2588  
2589 =back
2590  
2591 =over 4
2592  
2593 =item attributes example 7
2594  
2595 # given: synopsis
2596  
2597 package Example;
2598  
2599 use Venus::Class 'attr';
2600  
2601 attr 'name';
2602  
2603 package main;
2604  
2605 $check = $check->attributes('name', 'string');
2606  
2607 # bless(..., 'Venus::Check')
2608  
2609 # my $result = $check->result(Example->new(name => rand));
2610  
2611 # Exception! (isa Venus::Check::Error) (see error_on_coded)
2612  
2613 =back
2614  
2615 =cut
2616  
2617 =head2 bool
2618  
2619 bool(coderef @code) (Venus::Check)
2620  
2621 The bool method configures the object to accept boolean values and returns the
2622 invocant.
2623  
2624 I<Since C<3.55>>
2625  
2626 =over 4
2627  
2628 =item bool example 1
2629  
2630 # given: synopsis
2631  
2632 package main;
2633  
2634 use Venus;
2635  
2636 $check = $check->bool;
2637  
2638 # bless(..., 'Venus::Check')
2639  
2640 # my $result = $check->eval(true);
2641  
2642 # true
2643  
2644 =back
2645  
2646 =over 4
2647  
2648 =item bool example 2
2649  
2650 # given: synopsis
2651  
2652 package main;
2653  
2654 use Venus;
2655  
2656 $check = $check->bool;
2657  
2658 # bless(..., 'Venus::Check')
2659  
2660 # my $result = $check->eval(1);
2661  
2662 # false
2663  
2664 =back
2665  
2666 =over 4
2667  
2668 =item bool example 3
2669  
2670 # given: synopsis
2671  
2672 package main;
2673  
2674 use Venus;
2675  
2676 $check = $check->bool;
2677  
2678 # bless(..., 'Venus::Check')
2679  
2680 # my $result = $check->result(true);
2681  
2682 # true
2683  
2684 =back
2685  
2686 =over 4
2687  
2688 =item bool example 4
2689  
2690 # given: synopsis
2691  
2692 package main;
2693  
2694 use Venus;
2695  
2696 $check = $check->bool;
2697  
2698 # bless(..., 'Venus::Check')
2699  
2700 # my $result = $check->result(1);
2701  
2702 # Exception! (isa Venus::Check::Error) (see error_on_coded)
2703  
2704 =back
2705  
2706 =cut
2707  
2708 =head2 boolean
2709  
2710 boolean(coderef @code) (Venus::Check)
2711  
2712 The boolean method configures the object to accept boolean values and returns
2713 the invocant.
2714  
2715 I<Since C<3.55>>
2716  
2717 =over 4
2718  
2719 =item boolean example 1
2720  
2721 # given: synopsis
2722  
2723 package main;
2724  
2725 use Venus;
2726  
2727 $check = $check->boolean;
2728  
2729 # bless(..., 'Venus::Check')
2730  
2731 # my $result = $check->eval(true);
2732  
2733 # true
2734  
2735 =back
2736  
2737 =over 4
2738  
2739 =item boolean example 2
2740  
2741 # given: synopsis
2742  
2743 package main;
2744  
2745 use Venus;
2746  
2747 $check = $check->boolean;
2748  
2749 # bless(..., 'Venus::Check')
2750  
2751 # my $result = $check->eval(1);
2752  
2753 # false
2754  
2755 =back
2756  
2757 =over 4
2758  
2759 =item boolean example 3
2760  
2761 # given: synopsis
2762  
2763 package main;
2764  
2765 use Venus;
2766  
2767 $check = $check->boolean;
2768  
2769 # bless(..., 'Venus::Check')
2770  
2771 # my $result = $check->result(true);
2772  
2773 # true
2774  
2775 =back
2776  
2777 =over 4
2778  
2779 =item boolean example 4
2780  
2781 # given: synopsis
2782  
2783 package main;
2784  
2785 use Venus;
2786  
2787 $check = $check->boolean;
2788  
2789 # bless(..., 'Venus::Check')
2790  
2791 # my $result = $check->result(1);
2792  
2793 # Exception! (isa Venus::Check::Error) (see error_on_coded)
2794  
2795 =back
2796  
2797 =cut
2798  
2799 =head2 branch
2800  
2801 branch(string @args) (Venus::Check)
2802  
2803 The branch method returns a new L<Venus::Check> object configured to evaluate a
2804 branch of logic from its source.
2805  
2806 I<Since C<3.55>>
2807  
2808 =over 4
2809  
2810 =item branch example 1
2811  
2812 # given: synopsis
2813  
2814 package main;
2815  
2816 my $branch = $check->branch('nested');
2817  
2818 # bless(..., 'Venus::Check')
2819  
2820 =back
2821  
2822 =cut
2823  
2824 =head2 clear
2825  
2826 clear() (Venus::Check)
2827  
2828 The clear method resets all registered conditions and returns the invocant.
2829  
2830 I<Since C<3.55>>
2831  
2832 =over 4
2833  
2834 =item clear example 1
2835  
2836 # given: synopsis
2837  
2838 package main;
2839  
2840 $check->any;
2841  
2842 $check = $check->clear;
2843  
2844 # bless(..., 'Venus::Check')
2845  
2846 =back
2847  
2848 =cut
2849  
2850 =head2 code
2851  
2852 code(coderef @code) (Venus::Check)
2853  
2854 The code method configures the object to accept code references and returns
2855 the invocant.
2856  
2857 I<Since C<3.55>>
2858  
2859 =over 4
2860  
2861 =item code example 1
2862  
2863 # given: synopsis
2864  
2865 package main;
2866  
2867 $check = $check->code;
2868  
2869 # bless(..., 'Venus::Check')
2870  
2871 # my $result = $check->eval(sub{});
2872  
2873 # true
2874  
2875 =back
2876  
2877 =over 4
2878  
2879 =item code example 2
2880  
2881 # given: synopsis
2882  
2883 package main;
2884  
2885 $check = $check->code;
2886  
2887 # bless(..., 'Venus::Check')
2888  
2889 # my $result = $check->eval({});
2890  
2891 # false
2892  
2893 =back
2894  
2895 =over 4
2896  
2897 =item code example 3
2898  
2899 # given: synopsis
2900  
2901 package main;
2902  
2903 $check = $check->code;
2904  
2905 # bless(..., 'Venus::Check')
2906  
2907 # my $result = $check->result(sub{});
2908  
2909 # sub{}
2910  
2911 =back
2912  
2913 =over 4
2914  
2915 =item code example 4
2916  
2917 # given: synopsis
2918  
2919 package main;
2920  
2921 $check = $check->code;
2922  
2923 # bless(..., 'Venus::Check')
2924  
2925 # my $result = $check->result({});
2926  
2927 # Exception! (isa Venus::Check::Error) (see error_on_coded)
2928  
2929 =back
2930  
2931 =cut
2932  
2933 =head2 coded
2934  
2935 coded(any $data, string $name) (Venus::Check)
2936  
2937 The coded method accepts a value and a type name returns the result of a
2938 L<Venus::What/coded> operation.
2939  
2940 I<Since C<3.55>>
2941  
2942 =over 4
2943  
2944 =item coded example 1
2945  
2946 # given: synopsis
2947  
2948 package main;
2949  
2950 $check = $check->coded('hello', 'string');
2951  
2952 # true
2953  
2954 =back
2955  
2956 =over 4
2957  
2958 =item coded example 2
2959  
2960 # given: synopsis
2961  
2962 package main;
2963  
2964 $check = $check->coded(12345, 'string');
2965  
2966 # false
2967  
2968 =back
2969  
2970 =cut
2971  
2972 =head2 coderef
2973  
2974 coderef(coderef @code) (Venus::Check)
2975  
2976 The coderef method configures the object to accept code references and returns
2977 the invocant.
2978  
2979 I<Since C<3.55>>
2980  
2981 =over 4
2982  
2983 =item coderef example 1
2984  
2985 # given: synopsis
2986  
2987 package main;
2988  
2989 $check = $check->coderef;
2990  
2991 # bless(..., 'Venus::Check')
2992  
2993 # my $result = $check->eval(sub{});
2994  
2995 # true
2996  
2997 =back
2998  
2999 =over 4
3000  
3001 =item coderef example 2
3002  
3003 # given: synopsis
3004  
3005 package main;
3006  
3007 $check = $check->coderef;
3008  
3009 # bless(..., 'Venus::Check')
3010  
3011 # my $result = $check->eval({});
3012  
3013 # false
3014  
3015 =back
3016  
3017 =over 4
3018  
3019 =item coderef example 3
3020  
3021 # given: synopsis
3022  
3023 package main;
3024  
3025 $check = $check->coderef;
3026  
3027 # bless(..., 'Venus::Check')
3028  
3029 # my $result = $check->result(sub{});
3030  
3031 # sub{}
3032  
3033 =back
3034  
3035 =over 4
3036  
3037 =item coderef example 4
3038  
3039 # given: synopsis
3040  
3041 package main;
3042  
3043 $check = $check->coderef;
3044  
3045 # bless(..., 'Venus::Check')
3046  
3047 # my $result = $check->result({});
3048  
3049 # Exception! (isa Venus::Check::Error) (see error_on_coded)
3050  
3051 =back
3052  
3053 =cut
3054  
3055 =head2 consumes
3056  
3057 consumes(string $role) (Venus::Check)
3058  
3059 The consumes method configures the object to accept objects which consume the
3060 role provided, and returns the invocant.
3061  
3062 I<Since C<3.55>>
3063  
3064 =over 4
3065  
3066 =item consumes example 1
3067  
3068 # given: synopsis
3069  
3070 package Example;
3071  
3072 use Venus::Class 'base';
3073  
3074 base 'Venus::Kind';
3075  
3076 package main;
3077  
3078 $check = $check->consumes('Venus::Role::Throwable');
3079  
3080 # bless(..., 'Venus::Check')
3081  
3082 # my $result = $check->eval(Example->new);
3083  
3084 # true
3085  
3086 =back
3087  
3088 =over 4
3089  
3090 =item consumes example 2
3091  
3092 # given: synopsis
3093  
3094 package Example;
3095  
3096 use Venus::Class 'base';
3097  
3098 base 'Venus::Kind';
3099  
3100 package main;
3101  
3102 $check = $check->consumes('Venus::Role::Knowable');
3103  
3104 # bless(..., 'Venus::Check')
3105  
3106 # my $result = $check->eval(Example->new);
3107  
3108 # false
3109  
3110 =back
3111  
3112 =over 4
3113  
3114 =item consumes example 3
3115  
3116 # given: synopsis
3117  
3118 package Example;
3119  
3120 use Venus::Class 'base';
3121  
3122 base 'Venus::Kind';
3123  
3124 package main;
3125  
3126 $check = $check->consumes('Venus::Role::Throwable');
3127  
3128 # bless(..., 'Venus::Check')
3129  
3130 # my $result = $check->result(Example->new);
3131  
3132 # bless(..., 'Example')
3133  
3134 =back
3135  
3136 =over 4
3137  
3138 =item consumes example 4
3139  
3140 # given: synopsis
3141  
3142 package main;
3143  
3144 $check = $check->consumes('Venus::Role::Knowable');
3145  
3146 # bless(..., 'Venus::Check')
3147  
3148 # my $result = $check->result({});
3149  
3150 # Exception! (isa Venus::Check::Error) (see error_on_coded)
3151  
3152 =back
3153  
3154 =over 4
3155  
3156 =item consumes example 5
3157  
3158 # given: synopsis
3159  
3160 package Example;
3161  
3162 use Venus::Class 'base';
3163  
3164 base 'Venus::Kind';
3165  
3166 package main;
3167  
3168 $check = $check->consumes('Venus::Role::Knowable');
3169  
3170 # bless(..., 'Venus::Check')
3171  
3172 # my $result = $check->result(Example->new);
3173  
3174 # Exception! (isa Venus::Check::Error) (see error_on_consumes)
3175  
3176 =back
3177  
3178 =cut
3179  
3180 =head2 defined
3181  
3182 defined(coderef @code) (Venus::Check)
3183  
3184 The defined method configures the object to accept any value that's not
3185 undefined and returns the invocant.
3186  
3187 I<Since C<3.55>>
3188  
3189 =over 4
3190  
3191 =item defined example 1
3192  
3193 # given: synopsis
3194  
3195 package main;
3196  
3197 $check = $check->defined;
3198  
3199 # bless(..., 'Venus::Check')
3200  
3201 # my $result = $check->eval('');
3202  
3203 # true
3204  
3205 =back
3206  
3207 =over 4
3208  
3209 =item defined example 2
3210  
3211 # given: synopsis
3212  
3213 package main;
3214  
3215 $check = $check->defined;
3216  
3217 # bless(..., 'Venus::Check')
3218  
3219 # my $result = $check->eval(undef);
3220  
3221 # false
3222  
3223 =back
3224  
3225 =over 4
3226  
3227 =item defined example 3
3228  
3229 # given: synopsis
3230  
3231 package main;
3232  
3233 $check = $check->defined;
3234  
3235 # bless(..., 'Venus::Check')
3236  
3237 # my $result = $check->result('');
3238  
3239 # ''
3240  
3241 =back
3242  
3243 =over 4
3244  
3245 =item defined example 4
3246  
3247 # given: synopsis
3248  
3249 package main;
3250  
3251 $check = $check->defined;
3252  
3253 # bless(..., 'Venus::Check')
3254  
3255 # my $result = $check->result(undef);
3256  
3257 # Exception! (isa Venus::Check::Error) (see error_on_defined)
3258  
3259 =back
3260  
3261 =cut
3262  
3263 =head2 dirhandle
3264  
3265 dirhandle(coderef @code) (Venus::Check)
3266  
3267 The dirhandle method configures the object to accept dirhandles and returns the
3268 invocant.
3269  
3270 I<Since C<4.15>>
3271  
3272 =over 4
3273  
3274 =item dirhandle example 1
3275  
3276 # given: synopsis
3277  
3278 package main;
3279  
3280 $check = $check->dirhandle;
3281  
3282 # bless(..., 'Venus::Check')
3283  
3284 # opendir my $dh, './t';
3285  
3286 # my $result = $check->eval($dh);
3287  
3288 # true
3289  
3290 =back
3291  
3292 =over 4
3293  
3294 =item dirhandle example 2
3295  
3296 # given: synopsis
3297  
3298 package main;
3299  
3300 $check = $check->dirhandle;
3301  
3302 # bless(..., 'Venus::Check')
3303  
3304 # opendir my $dh, './xyz';
3305  
3306 # my $result = $check->eval($dh);
3307  
3308 # false
3309  
3310 =back
3311  
3312 =over 4
3313  
3314 =item dirhandle example 3
3315  
3316 # given: synopsis
3317  
3318 package main;
3319  
3320 $check = $check->dirhandle;
3321  
3322 # bless(..., 'Venus::Check')
3323  
3324 # opendir my $dh, './t';
3325  
3326 # my $result = $check->result($dh);
3327  
3328 # \*{'::$dh'}
3329  
3330 =back
3331  
3332 =over 4
3333  
3334 =item dirhandle example 4
3335  
3336 # given: synopsis
3337  
3338 package main;
3339  
3340 $check = $check->dirhandle;
3341  
3342 # bless(..., 'Venus::Check')
3343  
3344 # opendir my $dh, './xyz';
3345  
3346 # my $result = $check->result($dh);
3347  
3348 # Exception! (isa Venus::Check::Error) (see error_on_dirhandle)
3349  
3350 =back
3351  
3352 =cut
3353  
3354 =head2 either
3355  
3356 either(string | within[arrayref, string] @args) (Venus::Check)
3357  
3358 The either method configures the object to accept "either" of the conditions
3359 provided, which may be a string or arrayref representing a method call, and
3360 returns the invocant.
3361  
3362 I<Since C<3.55>>
3363  
3364 =over 4
3365  
3366 =item either example 1
3367  
3368 # given: synopsis
3369  
3370 package main;
3371  
3372 $check = $check->either('string', 'number');
3373  
3374 # bless(..., 'Venus::Check')
3375  
3376 # my $result = $check->eval('hello');
3377  
3378 # true
3379  
3380 =back
3381  
3382 =over 4
3383  
3384 =item either example 2
3385  
3386 # given: synopsis
3387  
3388 package main;
3389  
3390 $check = $check->either('string', 'number');
3391  
3392 # bless(..., 'Venus::Check')
3393  
3394 # my $result = $check->eval(rand);
3395  
3396 # false
3397  
3398 =back
3399  
3400 =over 4
3401  
3402 =item either example 3
3403  
3404 # given: synopsis
3405  
3406 package main;
3407  
3408 $check = $check->either('string', 'number');
3409  
3410 # bless(..., 'Venus::Check')
3411  
3412 # my $result = $check->result('hello');
3413  
3414 # 'hello'
3415  
3416 =back
3417  
3418 =over 4
3419  
3420 =item either example 4
3421  
3422 # given: synopsis
3423  
3424 package main;
3425  
3426 $check = $check->either('string', 'number');
3427  
3428 # bless(..., 'Venus::Check')
3429  
3430 # my $result = $check->result(rand);
3431  
3432 # Exception! (isa Venus::Check::Error) (see error_on_either)
3433  
3434 =back
3435  
3436 =cut
3437  
3438 =head2 enum
3439  
3440 enum(string @args) (Venus::Check)
3441  
3442 The enum method configures the object to accept any one of the provide options,
3443 and returns the invocant.
3444  
3445 I<Since C<3.55>>
3446  
3447 =over 4
3448  
3449 =item enum example 1
3450  
3451 # given: synopsis
3452  
3453 package main;
3454  
3455 $check = $check->enum('black', 'white', 'grey');
3456  
3457 # bless(..., 'Venus::Check')
3458  
3459 # my $result = $check->eval('black');
3460  
3461 # true
3462  
3463 =back
3464  
3465 =over 4
3466  
3467 =item enum example 2
3468  
3469 # given: synopsis
3470  
3471 package main;
3472  
3473 $check = $check->enum('black', 'white', 'grey');
3474  
3475 # bless(..., 'Venus::Check')
3476  
3477 # my $result = $check->eval('purple');
3478  
3479 # false
3480  
3481 =back
3482  
3483 =over 4
3484  
3485 =item enum example 3
3486  
3487 # given: synopsis
3488  
3489 package main;
3490  
3491 $check = $check->enum('black', 'white', 'grey');
3492  
3493 # bless(..., 'Venus::Check')
3494  
3495 # my $result = $check->result('black');
3496  
3497 # 'black'
3498  
3499 =back
3500  
3501 =over 4
3502  
3503 =item enum example 4
3504  
3505 # given: synopsis
3506  
3507 package main;
3508  
3509 $check = $check->enum('black', 'white', 'grey');
3510  
3511 # bless(..., 'Venus::Check')
3512  
3513 # my $result = $check->result(undef);
3514  
3515 # Exception! (isa Venus::Check::Error) (see error_on_defined)
3516  
3517 =back
3518  
3519 =over 4
3520  
3521 =item enum example 5
3522  
3523 # given: synopsis
3524  
3525 package main;
3526  
3527 $check = $check->enum('black', 'white', 'grey');
3528  
3529 # bless(..., 'Venus::Check')
3530  
3531 # my $result = $check->result('purple');
3532  
3533 # Exception! (isa Venus::Check::Error) (see error_on_enum)
3534  
3535 =back
3536  
3537 =cut
3538  
3539 =head2 eval
3540  
3541 eval(any $data) (any)
3542  
3543 The eval method returns true or false if the data provided passes the
3544 registered conditions.
3545  
3546 I<Since C<3.55>>
3547  
3548 =over 4
3549  
3550 =item eval example 1
3551  
3552 # given: synopsis
3553  
3554 package main;
3555  
3556 my $eval = $check->eval;
3557  
3558 # false
3559  
3560 =back
3561  
3562 =over 4
3563  
3564 =item eval example 2
3565  
3566 # given: synopsis
3567  
3568 package main;
3569  
3570 my $eval = $check->any->eval('');
3571  
3572 # true
3573  
3574 =back
3575  
3576 =cut
3577  
3578 =head2 evaled
3579  
3580 evaled() (boolean)
3581  
3582 The evaled method returns true if L</eval> has previously been executed, and
3583 false otherwise.
3584  
3585 I<Since C<3.35>>
3586  
3587 =over 4
3588  
3589 =item evaled example 1
3590  
3591 # given: synopsis
3592  
3593 package main;
3594  
3595 my $evaled = $check->evaled;
3596  
3597 # false
3598  
3599 =back
3600  
3601 =over 4
3602  
3603 =item evaled example 2
3604  
3605 # given: synopsis
3606  
3607 package main;
3608  
3609 $check->any->eval;
3610  
3611 my $evaled = $check->evaled;
3612  
3613 # true
3614  
3615 =back
3616  
3617 =cut
3618  
3619 =head2 evaler
3620  
3621 evaler(any @args) (coderef)
3622  
3623 The evaler method returns a coderef which calls the L</eval> method with the
3624 invocant when called.
3625  
3626 I<Since C<3.55>>
3627  
3628 =over 4
3629  
3630 =item evaler example 1
3631  
3632 # given: synopsis
3633  
3634 package main;
3635  
3636 my $evaler = $check->evaler;
3637  
3638 # sub{...}
3639  
3640 # my $result = $evaler->();
3641  
3642 # false
3643  
3644 =back
3645  
3646 =over 4
3647  
3648 =item evaler example 2
3649  
3650 # given: synopsis
3651  
3652 package main;
3653  
3654 my $evaler = $check->any->evaler;
3655  
3656 # sub{...}
3657  
3658 # my $result = $evaler->();
3659  
3660 # true
3661  
3662 =back
3663  
3664 =cut
3665  
3666 =head2 fail
3667  
3668 fail(any $data, hashref $meta) (boolean)
3669  
3670 The fail method captures data related to a failure and returns false.
3671  
3672 I<Since C<3.55>>
3673  
3674 =over 4
3675  
3676 =item fail example 1
3677  
3678 # given: synopsis
3679  
3680 package main;
3681  
3682 my $fail = $check->fail('...', {
3683 from => 'caller',
3684 });
3685  
3686 # false
3687  
3688 =back
3689  
3690 =cut
3691  
3692 =head2 failed
3693  
3694 failed() (boolean)
3695  
3696 The failed method returns true if the result of the last operation was a
3697 failure, otherwise returns false.
3698  
3699 I<Since C<3.55>>
3700  
3701 =over 4
3702  
3703 =item failed example 1
3704  
3705 # given: synopsis
3706  
3707 package main;
3708  
3709 my $failed = $check->failed;
3710  
3711 # false
3712  
3713 =back
3714  
3715 =over 4
3716  
3717 =item failed example 2
3718  
3719 # given: synopsis
3720  
3721 package main;
3722  
3723 $check->string->eval(12345);
3724  
3725 my $failed = $check->failed;
3726  
3727 # true
3728  
3729 =back
3730  
3731 =over 4
3732  
3733 =item failed example 3
3734  
3735 # given: synopsis
3736  
3737 package main;
3738  
3739 $check->string->eval('hello');
3740  
3741 my $failed = $check->failed;
3742  
3743 # false
3744  
3745 =back
3746  
3747 =cut
3748  
3749 =head2 filehandle
3750  
3751 filehandle(coderef @code) (Venus::Check)
3752  
3753 The filehandle method configures the object to accept filehandles and returns the
3754 invocant.
3755  
3756 I<Since C<4.15>>
3757  
3758 =over 4
3759  
3760 =item filehandle example 1
3761  
3762 # given: synopsis
3763  
3764 package main;
3765  
3766 $check = $check->filehandle;
3767  
3768 # bless(..., 'Venus::Check')
3769  
3770 # open my $fh, './t/Venus.t';
3771  
3772 # my $result = $check->eval($fh);
3773  
3774 # true
3775  
3776 =back
3777  
3778 =over 4
3779  
3780 =item filehandle example 2
3781  
3782 # given: synopsis
3783  
3784 package main;
3785  
3786 $check = $check->filehandle;
3787  
3788 # bless(..., 'Venus::Check')
3789  
3790 # open my $fh, './xyz/Venus.t';
3791  
3792 # my $result = $check->eval($fh);
3793  
3794 # false
3795  
3796 =back
3797  
3798 =over 4
3799  
3800 =item filehandle example 3
3801  
3802 # given: synopsis
3803  
3804 package main;
3805  
3806 $check = $check->filehandle;
3807  
3808 # bless(..., 'Venus::Check')
3809  
3810 # open my $fh, './t/Venus.t';
3811  
3812 # my $result = $check->result($fh);
3813  
3814 # \*{'::$fh'}
3815  
3816 =back
3817  
3818 =over 4
3819  
3820 =item filehandle example 4
3821  
3822 # given: synopsis
3823  
3824 package main;
3825  
3826 $check = $check->filehandle;
3827  
3828 # bless(..., 'Venus::Check')
3829  
3830 # open my $fh, './xyz/Venus.t';
3831  
3832 # my $result = $check->result($fh);
3833  
3834 # Exception! (isa Venus::Check::Error) (see error_on_filehandle)
3835  
3836 =back
3837  
3838 =cut
3839  
3840 =head2 float
3841  
3842 float(coderef @code) (Venus::Check)
3843  
3844 The float method configures the object to accept floating-point values and
3845 returns the invocant.
3846  
3847 I<Since C<3.55>>
3848  
3849 =over 4
3850  
3851 =item float example 1
3852  
3853 # given: synopsis
3854  
3855 package main;
3856  
3857 $check = $check->float;
3858  
3859 # bless(..., 'Venus::Check')
3860  
3861 # my $result = $check->eval(1.2345);
3862  
3863 # true
3864  
3865 =back
3866  
3867 =over 4
3868  
3869 =item float example 2
3870  
3871 # given: synopsis
3872  
3873 package main;
3874  
3875 $check = $check->float;
3876  
3877 # bless(..., 'Venus::Check')
3878  
3879 # my $result = $check->eval(12345);
3880  
3881 # false
3882  
3883 =back
3884  
3885 =over 4
3886  
3887 =item float example 3
3888  
3889 # given: synopsis
3890  
3891 package main;
3892  
3893 $check = $check->float;
3894  
3895 # bless(..., 'Venus::Check')
3896  
3897 # my $result = $check->result(1.2345);
3898  
3899 # 1.2345
3900  
3901 =back
3902  
3903 =over 4
3904  
3905 =item float example 4
3906  
3907 # given: synopsis
3908  
3909 package main;
3910  
3911 $check = $check->float;
3912  
3913 # bless(..., 'Venus::Check')
3914  
3915 # my $result = $check->result(12345);
3916  
3917 # Exception! (isa Venus::Check::Error) (see error_on_coded)
3918  
3919 =back
3920  
3921 =cut
3922  
3923 =head2 glob
3924  
3925 glob(coderef @code) (Venus::Check)
3926  
3927 The glob method configures the object to accept typeglobs and returns the
3928 invocant.
3929  
3930 I<Since C<4.15>>
3931  
3932 =over 4
3933  
3934 =item glob example 1
3935  
3936 # given: synopsis
3937  
3938 package main;
3939  
3940 $check = $check->glob;
3941  
3942 # bless(..., 'Venus::Check')
3943  
3944 # my $result = $check->eval(\*main);
3945  
3946 # true
3947  
3948 =back
3949  
3950 =over 4
3951  
3952 =item glob example 2
3953  
3954 # given: synopsis
3955  
3956 package main;
3957  
3958 $check = $check->glob;
3959  
3960 # bless(..., 'Venus::Check')
3961  
3962 # my $result = $check->eval(*main);
3963  
3964 # false
3965  
3966 =back
3967  
3968 =over 4
3969  
3970 =item glob example 3
3971  
3972 # given: synopsis
3973  
3974 package main;
3975  
3976 $check = $check->glob;
3977  
3978 # bless(..., 'Venus::Check')
3979  
3980 # my $result = $check->result(\*main);
3981  
3982 # \*::main
3983  
3984 =back
3985  
3986 =over 4
3987  
3988 =item glob example 4
3989  
3990 # given: synopsis
3991  
3992 package main;
3993  
3994 $check = $check->glob;
3995  
3996 # bless(..., 'Venus::Check')
3997  
3998 # my $result = $check->result(*main);
3999  
4000 # Exception! (isa Venus::Check::Error) (see error_on_typeglob)
4001  
4002 =back
4003  
4004 =cut
4005  
4006 =head2 hash
4007  
4008 hash(coderef @code) (Venus::Check)
4009  
4010 The hash method configures the object to accept hash references and returns
4011 the invocant.
4012  
4013 I<Since C<3.55>>
4014  
4015 =over 4
4016  
4017 =item hash example 1
4018  
4019 # given: synopsis
4020  
4021 package main;
4022  
4023 $check = $check->hash;
4024  
4025 # bless(..., 'Venus::Check')
4026  
4027 # my $result = $check->eval({});
4028  
4029 # true
4030  
4031 =back
4032  
4033 =over 4
4034  
4035 =item hash example 2
4036  
4037 # given: synopsis
4038  
4039 package main;
4040  
4041 $check = $check->hash;
4042  
4043 # bless(..., 'Venus::Check')
4044  
4045 # my $result = $check->eval([]);
4046  
4047 # false
4048  
4049 =back
4050  
4051 =over 4
4052  
4053 =item hash example 3
4054  
4055 # given: synopsis
4056  
4057 package main;
4058  
4059 $check = $check->hash;
4060  
4061 # bless(..., 'Venus::Check')
4062  
4063 # my $result = $check->result({});
4064  
4065 # {}
4066  
4067 =back
4068  
4069 =over 4
4070  
4071 =item hash example 4
4072  
4073 # given: synopsis
4074  
4075 package main;
4076  
4077 $check = $check->hash;
4078  
4079 # bless(..., 'Venus::Check')
4080  
4081 # my $result = $check->result([]);
4082  
4083 # Exception! (isa Venus::Check::Error) (see error_on_coded)
4084  
4085 =back
4086  
4087 =cut
4088  
4089 =head2 hashkeys
4090  
4091 hashkeys(string | within[arrayref, string] @args) (Venus::Check)
4092  
4093 The hashkeys method configures the object to accept hash based values
4094 containing the keys whose values' match the specified types, and returns the
4095 invocant.
4096  
4097 I<Since C<3.55>>
4098  
4099 =over 4
4100  
4101 =item hashkeys example 1
4102  
4103 # given: synopsis
4104  
4105 package main;
4106  
4107 $check = $check->hashkeys('rand', 'float');
4108  
4109 # bless(..., 'Venus::Check')
4110  
4111 # my $result = $check->eval({rand => rand});
4112  
4113 # true
4114  
4115 =back
4116  
4117 =over 4
4118  
4119 =item hashkeys example 2
4120  
4121 # given: synopsis
4122  
4123 package main;
4124  
4125 $check = $check->hashkeys('rand', 'float');
4126  
4127 # bless(..., 'Venus::Check')
4128  
4129 # my $result = $check->eval({});
4130  
4131 # false
4132  
4133 =back
4134  
4135 =over 4
4136  
4137 =item hashkeys example 3
4138  
4139 # given: synopsis
4140  
4141 package main;
4142  
4143 $check = $check->hashkeys('rand', 'float');
4144  
4145 # bless(..., 'Venus::Check')
4146  
4147 # my $result = $check->result({rand => rand});
4148  
4149 # {rand => rand}
4150  
4151 =back
4152  
4153 =over 4
4154  
4155 =item hashkeys example 4
4156  
4157 # given: synopsis
4158  
4159 package main;
4160  
4161 $check = $check->hashkeys('rand', 'float');
4162  
4163 # bless(..., 'Venus::Check')
4164  
4165 # my $result = $check->result(undef);
4166  
4167 # Exception! (isa Venus::Check::Error) (see error_on_defined)
4168  
4169 =back
4170  
4171 =over 4
4172  
4173 =item hashkeys example 5
4174  
4175 # given: synopsis
4176  
4177 package main;
4178  
4179 $check = $check->hashkeys('rand', 'float');
4180  
4181 # bless(..., 'Venus::Check')
4182  
4183 # my $result = $check->result([]);
4184  
4185 # Exception! (isa Venus::Check::Error) (see error_on_hashref)
4186  
4187 =back
4188  
4189 =over 4
4190  
4191 =item hashkeys example 6
4192  
4193 # given: synopsis
4194  
4195 package main;
4196  
4197 $check = $check->hashkeys('rand', 'float', 'name');
4198  
4199 # bless(..., 'Venus::Check')
4200  
4201 # my $result = $check->result({rand => rand});
4202  
4203 # Exception! (isa Venus::Check::Error) (see error_on_pairs)
4204  
4205 =back
4206  
4207 =over 4
4208  
4209 =item hashkeys example 7
4210  
4211 # given: synopsis
4212  
4213 package main;
4214  
4215 $check = $check->hashkeys('rand', 'float');
4216  
4217 # bless(..., 'Venus::Check')
4218  
4219 # my $result = $check->result({rndm => rand});
4220  
4221 # Exception! (isa Venus::Check::Error) (see error_on_missing)
4222  
4223 =back
4224  
4225 =cut
4226  
4227 =head2 hashref
4228  
4229 hashref(coderef @code) (Venus::Check)
4230  
4231 The hashref method configures the object to accept hash references and returns
4232 the invocant.
4233  
4234 I<Since C<3.55>>
4235  
4236 =over 4
4237  
4238 =item hashref example 1
4239  
4240 # given: synopsis
4241  
4242 package main;
4243  
4244 $check = $check->hashref;
4245  
4246 # bless(..., 'Venus::Check')
4247  
4248 # my $result = $check->eval({});
4249  
4250 # true
4251  
4252 =back
4253  
4254 =over 4
4255  
4256 =item hashref example 2
4257  
4258 # given: synopsis
4259  
4260 package main;
4261  
4262 $check = $check->hashref;
4263  
4264 # bless(..., 'Venus::Check')
4265  
4266 # my $result = $check->eval([]);
4267  
4268 # false
4269  
4270 =back
4271  
4272 =over 4
4273  
4274 =item hashref example 3
4275  
4276 # given: synopsis
4277  
4278 package main;
4279  
4280 $check = $check->hashref;
4281  
4282 # bless(..., 'Venus::Check')
4283  
4284 # my $result = $check->result({});
4285  
4286 # {}
4287  
4288 =back
4289  
4290 =over 4
4291  
4292 =item hashref example 4
4293  
4294 # given: synopsis
4295  
4296 package main;
4297  
4298 $check = $check->hashref;
4299  
4300 # bless(..., 'Venus::Check')
4301  
4302 # my $result = $check->result([]);
4303  
4304 # Exception! (isa Venus::Check::Error) (see error_on_coded)
4305  
4306 =back
4307  
4308 =cut
4309  
4310 =head2 identity
4311  
4312 identity(string $name) (Venus::Check)
4313  
4314 The identity method configures the object to accept objects of the type
4315 specified as the argument, and returns the invocant.
4316  
4317 I<Since C<3.55>>
4318  
4319 =over 4
4320  
4321 =item identity example 1
4322  
4323 # given: synopsis
4324  
4325 package main;
4326  
4327 $check = $check->identity('Venus::Check');
4328  
4329 # bless(..., 'Venus::Check')
4330  
4331 # my $result = $check->eval(Venus::Check->new);
4332  
4333 # true
4334  
4335 =back
4336  
4337 =over 4
4338  
4339 =item identity example 2
4340  
4341 # given: synopsis
4342  
4343 package main;
4344  
4345 use Venus::Config;
4346  
4347 $check = $check->identity('Venus::Check');
4348  
4349 # bless(..., 'Venus::Check')
4350  
4351 # my $result = $check->eval(Venus::Config->new);
4352  
4353 # false
4354  
4355 =back
4356  
4357 =over 4
4358  
4359 =item identity example 3
4360  
4361 # given: synopsis
4362  
4363 package main;
4364  
4365 $check = $check->identity('Venus::Check');
4366  
4367 # bless(..., 'Venus::Check')
4368  
4369 # my $result = $check->result(Venus::Check->new);
4370  
4371 # bless(..., 'Venus::Check')
4372  
4373 =back
4374  
4375 =over 4
4376  
4377 =item identity example 4
4378  
4379 # given: synopsis
4380  
4381 package main;
4382  
4383 $check = $check->identity('Venus::Check');
4384  
4385 # bless(..., 'Venus::Check')
4386  
4387 # my $result = $check->result({});
4388  
4389 # Exception! (isa Venus::Check::Error) (see error_on_coded)
4390  
4391 =back
4392  
4393 =over 4
4394  
4395 =item identity example 5
4396  
4397 # given: synopsis
4398  
4399 package main;
4400  
4401 use Venus::Config;
4402  
4403 $check = $check->identity('Venus::Check');
4404  
4405 # bless(..., 'Venus::Check')
4406  
4407 # my $result = $check->result(Venus::Config->new);
4408  
4409 # Exception! (isa Venus::Check::Error) (see error_on_identity)
4410  
4411 =back
4412  
4413 =cut
4414  
4415 =head2 includes
4416  
4417 includes(string | within[arrayref, string] @args) (Venus::Check)
4418  
4419 The include method configures the object to accept "all" of the conditions
4420 provided, which may be a string or arrayref representing a method call, and
4421 returns the invocant.
4422  
4423 I<Since C<3.55>>
4424  
4425 =over 4
4426  
4427 =item includes example 1
4428  
4429 # given: synopsis
4430  
4431 package main;
4432  
4433 $check = $check->includes('string', 'yesno');
4434  
4435 # bless(..., 'Venus::Check')
4436  
4437 # my $result = $check->eval('yes');
4438  
4439 # true
4440  
4441 =back
4442  
4443 =over 4
4444  
4445 =item includes example 2
4446  
4447 # given: synopsis
4448  
4449 package main;
4450  
4451 $check = $check->includes('string', 'yesno');
4452  
4453 # bless(..., 'Venus::Check')
4454  
4455 # my $result = $check->eval(0);
4456  
4457 # false
4458  
4459 =back
4460  
4461 =over 4
4462  
4463 =item includes example 3
4464  
4465 # given: synopsis
4466  
4467 package main;
4468  
4469 $check = $check->includes('string', 'yesno');
4470  
4471 # bless(..., 'Venus::Check')
4472  
4473 # my $result = $check->result('Yes');
4474  
4475 # 'Yes'
4476  
4477 =back
4478  
4479 =over 4
4480  
4481 =item includes example 4
4482  
4483 # given: synopsis
4484  
4485 package main;
4486  
4487 $check = $check->includes('string', 'yesno');
4488  
4489 # bless(..., 'Venus::Check')
4490  
4491 # my $result = $check->result(1);
4492  
4493 # Exception! (isa Venus::Check::Error) (see error_on_includes)
4494  
4495 =back
4496  
4497 =cut
4498  
4499 =head2 inherits
4500  
4501 inherits(string $base) (Venus::Check)
4502  
4503 The inherits method configures the object to accept objects of the type
4504 specified as the argument, and returns the invocant. This method is a proxy for
4505 the L</identity> method.
4506  
4507 I<Since C<3.55>>
4508  
4509 =over 4
4510  
4511 =item inherits example 1
4512  
4513 # given: synopsis
4514  
4515 package main;
4516  
4517 $check = $check->inherits('Venus::Kind::Utility');
4518  
4519 # bless(..., 'Venus::Check')
4520  
4521 # my $result = $check->eval(Venus::Check->new);
4522  
4523 # true
4524  
4525 =back
4526  
4527 =over 4
4528  
4529 =item inherits example 2
4530  
4531 # given: synopsis
4532  
4533 package main;
4534  
4535 $check = $check->inherits('Venus::Kind::Value');
4536  
4537 # bless(..., 'Venus::Check')
4538  
4539 # my $result = $check->eval(Venus::Check->new);
4540  
4541 # false
4542  
4543 =back
4544  
4545 =over 4
4546  
4547 =item inherits example 3
4548  
4549 # given: synopsis
4550  
4551 package main;
4552  
4553 $check = $check->inherits('Venus::Kind::Utility');
4554  
4555 # bless(..., 'Venus::Check')
4556  
4557 # my $result = $check->result(Venus::Check->new);
4558  
4559 # bless(..., 'Venus::Check')
4560  
4561 =back
4562  
4563 =over 4
4564  
4565 =item inherits example 4
4566  
4567 # given: synopsis
4568  
4569 package main;
4570  
4571 $check = $check->inherits('Venus::Kind::Value');
4572  
4573 # bless(..., 'Venus::Check')
4574  
4575 # my $result = $check->result({});
4576  
4577 # Exception! (isa Venus::Check::Error) (see error_on_coded)
4578  
4579 =back
4580  
4581 =over 4
4582  
4583 =item inherits example 5
4584  
4585 # given: synopsis
4586  
4587 package main;
4588  
4589 $check = $check->inherits('Venus::Kind::Value');
4590  
4591 # bless(..., 'Venus::Check')
4592  
4593 # my $result = $check->result(Venus::Check->new);
4594  
4595 # Exception! (isa Venus::Check::Error) (see error_on_inherits)
4596  
4597 =back
4598  
4599 =cut
4600  
4601 =head2 integrates
4602  
4603 integrates(string $role) (Venus::Check)
4604  
4605 The integrates method configures the object to accept objects that support the
4606 C<"does"> behavior and consumes the "role" specified as the argument, and
4607 returns the invocant.
4608  
4609 I<Since C<3.55>>
4610  
4611 =over 4
4612  
4613 =item integrates example 1
4614  
4615 # given: synopsis
4616  
4617 package main;
4618  
4619 $check = $check->integrates('Venus::Role::Throwable');
4620  
4621 # bless(..., 'Venus::Check')
4622  
4623 # my $result = $check->eval(Venus::Check->new);
4624  
4625 # true
4626  
4627 =back
4628  
4629 =over 4
4630  
4631 =item integrates example 2
4632  
4633 # given: synopsis
4634  
4635 package main;
4636  
4637 $check = $check->integrates('Venus::Role::Knowable');
4638  
4639 # bless(..., 'Venus::Check')
4640  
4641 # my $result = $check->eval(Venus::Check->new);
4642  
4643 # false
4644  
4645 =back
4646  
4647 =over 4
4648  
4649 =item integrates example 3
4650  
4651 # given: synopsis
4652  
4653 package main;
4654  
4655 $check = $check->integrates('Venus::Role::Throwable');
4656  
4657 # bless(..., 'Venus::Check')
4658  
4659 # my $result = $check->result(Venus::Check->new);
4660  
4661 # bless(..., 'Venus::Check')
4662  
4663 =back
4664  
4665 =over 4
4666  
4667 =item integrates example 4
4668  
4669 # given: synopsis
4670  
4671 package main;
4672  
4673 $check = $check->integrates('Venus::Role::Knowable');
4674  
4675 # bless(..., 'Venus::Check')
4676  
4677 # my $result = $check->result({});
4678  
4679 # Exception! (isa Venus::Check::Error) (see error_on_coded)
4680  
4681 =back
4682  
4683 =over 4
4684  
4685 =item integrates example 5
4686  
4687 # given: synopsis
4688  
4689 package main;
4690  
4691 $check = $check->integrates('Venus::Role::Knowable');
4692  
4693 # bless(..., 'Venus::Check')
4694  
4695 # my $result = $check->result(Venus::Check->new);
4696  
4697 # Exception! (isa Venus::Check::Error) (see error_on_consumes)
4698  
4699 =back
4700  
4701 =cut
4702  
4703 =head2 maybe
4704  
4705 maybe(string | within[arrayref, string] @args) (Venus::Check)
4706  
4707 The maybe method configures the object to accept the type provided as an
4708 argument, or undef, and returns the invocant.
4709  
4710 I<Since C<3.55>>
4711  
4712 =over 4
4713  
4714 =item maybe example 1
4715  
4716 # given: synopsis
4717  
4718 package main;
4719  
4720 $check = $check->maybe('string');
4721  
4722 # bless(..., 'Venus::Check')
4723  
4724 # my $result = $check->eval('');
4725  
4726 # true
4727  
4728 =back
4729  
4730 =over 4
4731  
4732 =item maybe example 2
4733  
4734 # given: synopsis
4735  
4736 package main;
4737  
4738 $check = $check->maybe('string');
4739  
4740 # bless(..., 'Venus::Check')
4741  
4742 # my $result = $check->eval([]);
4743  
4744 # false
4745  
4746 =back
4747  
4748 =over 4
4749  
4750 =item maybe example 3
4751  
4752 # given: synopsis
4753  
4754 package main;
4755  
4756 $check = $check->maybe('string');
4757  
4758 # bless(..., 'Venus::Check')
4759  
4760 # my $result = $check->result(undef);
4761  
4762 # undef
4763  
4764 =back
4765  
4766 =over 4
4767  
4768 =item maybe example 4
4769  
4770 # given: synopsis
4771  
4772 package main;
4773  
4774 $check = $check->maybe('string');
4775  
4776 # bless(..., 'Venus::Check')
4777  
4778 # my $result = $check->result(0);
4779  
4780 # Exception! (isa Venus::Check::Error) (see error_on_either)
4781  
4782 =back
4783  
4784 =over 4
4785  
4786 =item maybe example 5
4787  
4788 # given: synopsis
4789  
4790 package main;
4791  
4792 $check = $check->maybe('string');
4793  
4794 # bless(..., 'Venus::Check')
4795  
4796 # my $result = $check->result([]);
4797  
4798 # Exception! (isa Venus::Check::Error) (see error_on_either)
4799  
4800 =back
4801  
4802 =cut
4803  
4804 =head2 new
4805  
4806 new(any @args) (Venus::Check)
4807  
4808 The new method constructs an instance of the package.
4809  
4810 I<Since C<4.15>>
4811  
4812 =over 4
4813  
4814 =item new example 1
4815  
4816 package main;
4817  
4818 use Venus::Check;
4819  
4820 my $new = Venus::Check->new;
4821  
4822 # bless(..., "Venus::Check")
4823  
4824 =back
4825  
4826 =cut
4827  
4828 =head2 number
4829  
4830 number(coderef @code) (Venus::Check)
4831  
4832 The number method configures the object to accept numberic values and returns
4833 the invocant.
4834  
4835 I<Since C<3.55>>
4836  
4837 =over 4
4838  
4839 =item number example 1
4840  
4841 # given: synopsis
4842  
4843 package main;
4844  
4845 $check = $check->number;
4846  
4847 # bless(..., 'Venus::Check')
4848  
4849 # my $result = $check->eval(1234);
4850  
4851 # true
4852  
4853 =back
4854  
4855 =over 4
4856  
4857 =item number example 2
4858  
4859 # given: synopsis
4860  
4861 package main;
4862  
4863 $check = $check->number;
4864  
4865 # bless(..., 'Venus::Check')
4866  
4867 # my $result = $check->eval(1.234);
4868  
4869 # false
4870  
4871 =back
4872  
4873 =over 4
4874  
4875 =item number example 3
4876  
4877 # given: synopsis
4878  
4879 package main;
4880  
4881 $check = $check->number;
4882  
4883 # bless(..., 'Venus::Check')
4884  
4885 # my $result = $check->result(1234);
4886  
4887 # 1234
4888  
4889 =back
4890  
4891 =over 4
4892  
4893 =item number example 4
4894  
4895 # given: synopsis
4896  
4897 package main;
4898  
4899 $check = $check->number;
4900  
4901 # bless(..., 'Venus::Check')
4902  
4903 # my $result = $check->result(1.234);
4904  
4905 # Exception! (isa Venus::Check::Error) (see error_on_coded)
4906  
4907 =back
4908  
4909 =cut
4910  
4911 =head2 object
4912  
4913 object(coderef @code) (Venus::Check)
4914  
4915 The object method configures the object to accept objects and returns the
4916 invocant.
4917  
4918 I<Since C<3.55>>
4919  
4920 =over 4
4921  
4922 =item object example 1
4923  
4924 # given: synopsis
4925  
4926 package main;
4927  
4928 $check = $check->object;
4929  
4930 # bless(..., 'Venus::Check')
4931  
4932 # my $result = $check->eval(bless{});
4933  
4934 # true
4935  
4936 =back
4937  
4938 =over 4
4939  
4940 =item object example 2
4941  
4942 # given: synopsis
4943  
4944 package main;
4945  
4946 $check = $check->object;
4947  
4948 # bless(..., 'Venus::Check')
4949  
4950 # my $result = $check->eval({});
4951  
4952 # false
4953  
4954 =back
4955  
4956 =over 4
4957  
4958 =item object example 3
4959  
4960 # given: synopsis
4961  
4962 package main;
4963  
4964 $check = $check->object;
4965  
4966 # bless(..., 'Venus::Check')
4967  
4968 # my $result = $check->result(bless{});
4969  
4970 # bless{}
4971  
4972 =back
4973  
4974 =over 4
4975  
4976 =item object example 4
4977  
4978 # given: synopsis
4979  
4980 package main;
4981  
4982 $check = $check->object;
4983  
4984 # bless(..., 'Venus::Check')
4985  
4986 # my $result = $check->result({});
4987  
4988 # Exception! (isa Venus::Check::Error) (see error_on_coded)
4989  
4990 =back
4991  
4992 =cut
4993  
4994 =head2 package
4995  
4996 package(coderef @code) (Venus::Check)
4997  
4998 The package method configures the object to accept package names (which are
4999 loaded) and returns the invocant.
5000  
5001 I<Since C<3.55>>
5002  
5003 =over 4
5004  
5005 =item package example 1
5006  
5007 # given: synopsis
5008  
5009 package main;
5010  
5011 $check = $check->package;
5012  
5013 # bless(..., 'Venus::Check')
5014  
5015 # my $result = $check->eval('Venus::Check');
5016  
5017 # true
5018  
5019 =back
5020  
5021 =over 4
5022  
5023 =item package example 2
5024  
5025 # given: synopsis
5026  
5027 package main;
5028  
5029 $check = $check->package;
5030  
5031 # bless(..., 'Venus::Check')
5032  
5033 # my $result = $check->eval('MyApp::Check');
5034  
5035 # false
5036  
5037 =back
5038  
5039 =over 4
5040  
5041 =item package example 3
5042  
5043 # given: synopsis
5044  
5045 package main;
5046  
5047 $check = $check->package;
5048  
5049 # bless(..., 'Venus::Check')
5050  
5051 # my $result = $check->result('Venus::Check');
5052  
5053 # 'Venus::Check'
5054  
5055 =back
5056  
5057 =over 4
5058  
5059 =item package example 4
5060  
5061 # given: synopsis
5062  
5063 package main;
5064  
5065 $check = $check->package;
5066  
5067 # bless(..., 'Venus::Check')
5068  
5069 # my $result = $check->result(0);
5070  
5071 # Exception! (isa Venus::Check::Error) (see error_on_coded)
5072  
5073 =back
5074  
5075 =over 4
5076  
5077 =item package example 5
5078  
5079 # given: synopsis
5080  
5081 package main;
5082  
5083 $check = $check->package;
5084  
5085 # bless(..., 'Venus::Check')
5086  
5087 # my $result = $check->result('main');
5088  
5089 # Exception! (isa Venus::Check::Error) (see error_on_package)
5090  
5091 =back
5092  
5093 =over 4
5094  
5095 =item package example 6
5096  
5097 # given: synopsis
5098  
5099 package main;
5100  
5101 $check = $check->package;
5102  
5103 # bless(..., 'Venus::Check')
5104  
5105 # my $result = $check->result('MyApp::Check');
5106  
5107 # Exception! (isa Venus::Check::Error) (see error_on_package_loaded)
5108  
5109 =back
5110  
5111 =cut
5112  
5113 =head2 pass
5114  
5115 pass(any $data, hashref $meta) (boolean)
5116  
5117 The pass method captures data related to a success and returns true.
5118  
5119 I<Since C<3.55>>
5120  
5121 =over 4
5122  
5123 =item pass example 1
5124  
5125 # given: synopsis
5126  
5127 package main;
5128  
5129 my $pass = $check->pass('...', {
5130 from => 'caller',
5131 });
5132  
5133 # true
5134  
5135 =back
5136  
5137 =cut
5138  
5139 =head2 passed
5140  
5141 passed() (boolean)
5142  
5143 The passed method returns true if the result of the last operation was a
5144 success, otherwise returns false.
5145  
5146 I<Since C<3.55>>
5147  
5148 =over 4
5149  
5150 =item passed example 1
5151  
5152 # given: synopsis
5153  
5154 package main;
5155  
5156 my $passed = $check->passed;
5157  
5158 # false
5159  
5160 =back
5161  
5162 =over 4
5163  
5164 =item passed example 2
5165  
5166 # given: synopsis
5167  
5168 package main;
5169  
5170 $check->string->eval('hello');
5171  
5172 my $passed = $check->passed;
5173  
5174 # true
5175  
5176 =back
5177  
5178 =over 4
5179  
5180 =item passed example 3
5181  
5182 # given: synopsis
5183  
5184 package main;
5185  
5186 $check->string->eval(12345);
5187  
5188 my $passed = $check->passed;
5189  
5190 # false
5191  
5192 =back
5193  
5194 =cut
5195  
5196 =head2 reference
5197  
5198 reference(coderef @code) (Venus::Check)
5199  
5200 The reference method configures the object to accept references and returns the
5201 invocant.
5202  
5203 I<Since C<3.55>>
5204  
5205 =over 4
5206  
5207 =item reference example 1
5208  
5209 # given: synopsis
5210  
5211 package main;
5212  
5213 $check = $check->reference;
5214  
5215 # bless(..., 'Venus::Check')
5216  
5217 # my $result = $check->eval([]);
5218  
5219 # true
5220  
5221 =back
5222  
5223 =over 4
5224  
5225 =item reference example 2
5226  
5227 # given: synopsis
5228  
5229 package main;
5230  
5231 $check = $check->reference;
5232  
5233 # bless(..., 'Venus::Check')
5234  
5235 # my $result = $check->eval('');
5236  
5237 # false
5238  
5239 =back
5240  
5241 =over 4
5242  
5243 =item reference example 3
5244  
5245 # given: synopsis
5246  
5247 package main;
5248  
5249 $check = $check->reference;
5250  
5251 # bless(..., 'Venus::Check')
5252  
5253 # my $result = $check->result([]);
5254  
5255 # []
5256  
5257 =back
5258  
5259 =over 4
5260  
5261 =item reference example 4
5262  
5263 # given: synopsis
5264  
5265 package main;
5266  
5267 $check = $check->reference;
5268  
5269 # bless(..., 'Venus::Check')
5270  
5271 # my $result = $check->result(undef);
5272  
5273 # Exception! (isa Venus::Check::Error) (see error_on_defined)
5274  
5275 =back
5276  
5277 =over 4
5278  
5279 =item reference example 5
5280  
5281 # given: synopsis
5282  
5283 package main;
5284  
5285 $check = $check->reference;
5286  
5287 # bless(..., 'Venus::Check')
5288  
5289 # my $result = $check->result('');
5290  
5291 # Exception! (isa Venus::Check::Error) (see error_on_reference)
5292  
5293 =back
5294  
5295 =cut
5296  
5297 =head2 regexp
5298  
5299 regexp(coderef @code) (Venus::Check)
5300  
5301 The regexp method configures the object to accept regular expression objects
5302 and returns the invocant.
5303  
5304 I<Since C<3.55>>
5305  
5306 =over 4
5307  
5308 =item regexp example 1
5309  
5310 # given: synopsis
5311  
5312 package main;
5313  
5314 $check = $check->regexp;
5315  
5316 # bless(..., 'Venus::Check')
5317  
5318 # my $result = $check->eval(qr//);
5319  
5320 # true
5321  
5322 =back
5323  
5324 =over 4
5325  
5326 =item regexp example 2
5327  
5328 # given: synopsis
5329  
5330 package main;
5331  
5332 $check = $check->regexp;
5333  
5334 # bless(..., 'Venus::Check')
5335  
5336 # my $result = $check->eval('');
5337  
5338 # false
5339  
5340 =back
5341  
5342 =over 4
5343  
5344 =item regexp example 3
5345  
5346 # given: synopsis
5347  
5348 package main;
5349  
5350 $check = $check->regexp;
5351  
5352 # bless(..., 'Venus::Check')
5353  
5354 # my $result = $check->result(qr//);
5355  
5356 # qr//
5357  
5358 =back
5359  
5360 =over 4
5361  
5362 =item regexp example 4
5363  
5364 # given: synopsis
5365  
5366 package main;
5367  
5368 $check = $check->regexp;
5369  
5370 # bless(..., 'Venus::Check')
5371  
5372 # my $result = $check->result('');
5373  
5374 # Exception! (isa Venus::Check::Error) (see error_on_coded)
5375  
5376 =back
5377  
5378 =cut
5379  
5380 =head2 result
5381  
5382 result(any @args) (any)
5383  
5384 The result method performs an L</eval> operation and returns the value provided
5385 on success, and on failure raises an exception.
5386  
5387 I<Since C<3.55>>
5388  
5389 =over 4
5390  
5391 =item result example 1
5392  
5393 # given: synopsis
5394  
5395 package main;
5396  
5397 $check->string;
5398  
5399 my $string = $check->result('hello');
5400  
5401 # 'hello'
5402  
5403 =back
5404  
5405 =over 4
5406  
5407 =item result example 2
5408  
5409 # given: synopsis
5410  
5411 package main;
5412  
5413 $check->string;
5414  
5415 my $string = $check->result(12345);
5416  
5417 # Exception! (isa Venus::Check::Error) (see error_on_coded)
5418  
5419 =back
5420  
5421 =over 4
5422  
5423 =item B<may raise> L<Venus::Check::Error> C<on.arrayref>
5424  
5425 # given: synopsis;
5426  
5427 $check->tuple('string');
5428  
5429 $check->result({});
5430  
5431 # Error! (on.arrayref)
5432  
5433 =back
5434  
5435 =over 4
5436  
5437 =item B<may raise> L<Venus::Check::Error> C<on.arrayref.count>
5438  
5439 # given: synopsis;
5440  
5441 $check->tuple('string', 'string');
5442  
5443 $check->result(['hello']);
5444  
5445 # Error! (on.arrayref.count)
5446  
5447 =back
5448  
5449 =over 4
5450  
5451 =item B<may raise> L<Venus::Check::Error> C<on.coded>
5452  
5453 # given: synopsis;
5454  
5455 $check->string;
5456  
5457 $check->result(12345);
5458  
5459 # Error! (on.coded)
5460  
5461 =back
5462  
5463 =over 4
5464  
5465 =item B<may raise> L<Venus::Check::Error> C<on.consumes>
5466  
5467 # given: synopsis;
5468  
5469 package Example;
5470  
5471 use Venus::Class;
5472  
5473 package main;
5474  
5475 $check->consumes('Venus::Role::Throwable');
5476  
5477 $check->result(Example->new);
5478  
5479 # Error! (on.consumes)
5480  
5481 =back
5482  
5483 =over 4
5484  
5485 =item B<may raise> L<Venus::Check::Error> C<on.defined>
5486  
5487 # given: synopsis;
5488  
5489 $check->string;
5490  
5491 $check->result(undef);
5492  
5493 # Error! (on.defined)
5494  
5495 =back
5496  
5497 =over 4
5498  
5499 =item B<may raise> L<Venus::Check::Error> C<on.dirhandle>
5500  
5501 # given: synopsis;
5502  
5503 $check->dirhandle;
5504  
5505 $check->result('hello');
5506  
5507 # Error! (on.dirhandle)
5508  
5509 =back
5510  
5511 =over 4
5512  
5513 =item B<may raise> L<Venus::Check::Error> C<on.either>
5514  
5515 # given: synopsis;
5516  
5517 $check->either('string', 'number');
5518  
5519 $check->result([]);
5520  
5521 # Error! (on.either)
5522  
5523 =back
5524  
5525 =over 4
5526  
5527 =item B<may raise> L<Venus::Check::Error> C<on.enum>
5528  
5529 # given: synopsis;
5530  
5531 $check->enum('this', 'that');
5532  
5533 $check->result('other');
5534  
5535 # Error! (on.enum)
5536  
5537 =back
5538  
5539 =over 4
5540  
5541 =item B<may raise> L<Venus::Check::Error> C<on.filehandle>
5542  
5543 # given: synopsis;
5544  
5545 $check->filehandle;
5546  
5547 $check->result('hello');
5548  
5549 # Error! (on.filehandle)
5550  
5551 =back
5552  
5553 =over 4
5554  
5555 =item B<may raise> L<Venus::Check::Error> C<on.hashref>
5556  
5557 # given: synopsis;
5558  
5559 $check->hashkeys('name', 'string');
5560  
5561 $check->result([]);
5562  
5563 # Error! (on.hashref)
5564  
5565 =back
5566  
5567 =over 4
5568  
5569 =item B<may raise> L<Venus::Check::Error> C<on.hashref.empty>
5570  
5571 # given: synopsis;
5572  
5573 $check->hashkeys('name', 'string');
5574  
5575 $check->result({});
5576  
5577 # Error! (on.hashref.empty)
5578  
5579 =back
5580  
5581 =over 4
5582  
5583 =item B<may raise> L<Venus::Check::Error> C<on.includes>
5584  
5585 # given: synopsis;
5586  
5587 $check->includes('string', 'number');
5588  
5589 $check->result([]);
5590  
5591 # Error! (on.includes)
5592  
5593 =back
5594  
5595 =over 4
5596  
5597 =item B<may raise> L<Venus::Check::Error> C<on.identity>
5598  
5599 # given: synopsis;
5600  
5601 $check->identity('Venus::String');
5602  
5603 $check->result(Venus::Check->new);
5604  
5605 # Error! (on.identity)
5606  
5607 =back
5608  
5609 =over 4
5610  
5611 =item B<may raise> L<Venus::Check::Error> C<on.inherits>
5612  
5613 # given: synopsis;
5614  
5615 $check->inherits('Venus::String');
5616  
5617 $check->result(Venus::Check->new);
5618  
5619 # Error! (on.inherits)
5620  
5621 =back
5622  
5623 =over 4
5624  
5625 =item B<may raise> L<Venus::Check::Error> C<on.missing>
5626  
5627 # given: synopsis;
5628  
5629 $check->attributes('name', 'string');
5630  
5631 $check->result(bless{});
5632  
5633 # Error! (on.missing)
5634  
5635 =back
5636  
5637 =over 4
5638  
5639 =item B<may raise> L<Venus::Check::Error> C<on.package>
5640  
5641 # given: synopsis;
5642  
5643 $check->package;
5644  
5645 $check->result('not-a-package!');
5646  
5647 # Error! (on.package)
5648  
5649 =back
5650  
5651 =over 4
5652  
5653 =item B<may raise> L<Venus::Check::Error> C<on.package.loaded>
5654  
5655 # given: synopsis;
5656  
5657 $check->package;
5658  
5659 $check->result('Example::Fake');
5660  
5661 # Error! (on.package.loaded)
5662  
5663 =back
5664  
5665 =over 4
5666  
5667 =item B<may raise> L<Venus::Check::Error> C<on.pairs>
5668  
5669 # given: synopsis;
5670  
5671 $check->hashkeys('name');
5672  
5673 $check->result({name => 'example'});
5674  
5675 # Error! (on.pairs)
5676  
5677 =back
5678  
5679 =over 4
5680  
5681 =item B<may raise> L<Venus::Check::Error> C<on.reference>
5682  
5683 # given: synopsis;
5684  
5685 $check->reference;
5686  
5687 $check->result('hello');
5688  
5689 # Error! (on.reference)
5690  
5691 =back
5692  
5693 =over 4
5694  
5695 =item B<may raise> L<Venus::Check::Error> C<on.typeglob>
5696  
5697 # given: synopsis;
5698  
5699 $check->glob;
5700  
5701 $check->result('hello');
5702  
5703 # Error! (on.typeglob)
5704  
5705 =back
5706  
5707 =over 4
5708  
5709 =item B<may raise> L<Venus::Check::Error> C<on.value>
5710  
5711 # given: synopsis;
5712  
5713 $check->value;
5714  
5715 $check->result([]);
5716  
5717 # Error! (on.value)
5718  
5719 =back
5720  
5721 =over 4
5722  
5723 =item B<may raise> L<Venus::Check::Error> C<on.yesno>
5724  
5725 # given: synopsis;
5726  
5727 $check->yesno;
5728  
5729 $check->result('maybe');
5730  
5731 # Error! (on.yesno)
5732  
5733 =back
5734  
5735 =cut
5736  
5737 =head2 routines
5738  
5739 routines(string @names) (Venus::Check)
5740  
5741 The routines method configures the object to accept an object having all of the
5742 routines provided, and returns the invocant.
5743  
5744 I<Since C<3.55>>
5745  
5746 =over 4
5747  
5748 =item routines example 1
5749  
5750 # given: synopsis
5751  
5752 package main;
5753  
5754 $check = $check->routines('result');
5755  
5756 # bless(..., 'Venus::Check')
5757  
5758 # my $result = $check->eval(Venus::Check->new);
5759  
5760 # true
5761  
5762 =back
5763  
5764 =over 4
5765  
5766 =item routines example 2
5767  
5768 # given: synopsis
5769  
5770 package main;
5771  
5772 use Venus::Config;
5773  
5774 $check = $check->routines('result');
5775  
5776 # bless(..., 'Venus::Check')
5777  
5778 # my $result = $check->eval(Venus::Config->new);
5779  
5780 # false
5781  
5782 =back
5783  
5784 =over 4
5785  
5786 =item routines example 3
5787  
5788 # given: synopsis
5789  
5790 package main;
5791  
5792 $check = $check->routines('result');
5793  
5794 # bless(..., 'Venus::Check')
5795  
5796 # my $result = $check->result(Venus::Check->new);
5797  
5798 # bless(..., 'Venus::Check')
5799  
5800 =back
5801  
5802 =over 4
5803  
5804 =item routines example 4
5805  
5806 # given: synopsis
5807  
5808 package main;
5809  
5810 use Venus::Config;
5811  
5812 $check = $check->routines('result');
5813  
5814 # bless(..., 'Venus::Check')
5815  
5816 # my $result = $check->result({});
5817  
5818 # Exception! (isa Venus::Check::Error) (see error_on_coded)
5819  
5820 =back
5821  
5822 =over 4
5823  
5824 =item routines example 5
5825  
5826 # given: synopsis
5827  
5828 package main;
5829  
5830 use Venus::Config;
5831  
5832 $check = $check->routines('result');
5833  
5834 # bless(..., 'Venus::Check')
5835  
5836 # my $result = $check->result(Venus::Config->new);
5837  
5838 # Exception! (isa Venus::Check::Error) (see error_on_missing)
5839  
5840 =back
5841  
5842 =cut
5843  
5844 =head2 scalar
5845  
5846 scalar(coderef @code) (Venus::Check)
5847  
5848 The scalar method configures the object to accept scalar references and returns
5849 the invocant.
5850  
5851 I<Since C<3.55>>
5852  
5853 =over 4
5854  
5855 =item scalar example 1
5856  
5857 # given: synopsis
5858  
5859 package main;
5860  
5861 $check = $check->scalar;
5862  
5863 # bless(..., 'Venus::Check')
5864  
5865 # my $result = $check->eval(\'');
5866  
5867 # true
5868  
5869 =back
5870  
5871 =over 4
5872  
5873 =item scalar example 2
5874  
5875 # given: synopsis
5876  
5877 package main;
5878  
5879 $check = $check->scalar;
5880  
5881 # bless(..., 'Venus::Check')
5882  
5883 # my $result = $check->eval('');
5884  
5885 # false
5886  
5887 =back
5888  
5889 =over 4
5890  
5891 =item scalar example 3
5892  
5893 # given: synopsis
5894  
5895 package main;
5896  
5897 $check = $check->scalar;
5898  
5899 # bless(..., 'Venus::Check')
5900  
5901 # my $result = $check->result(\'');
5902  
5903 # \''
5904  
5905 =back
5906  
5907 =over 4
5908  
5909 =item scalar example 4
5910  
5911 # given: synopsis
5912  
5913 package main;
5914  
5915 $check = $check->scalar;
5916  
5917 # bless(..., 'Venus::Check')
5918  
5919 # my $result = $check->result('');
5920  
5921 # Exception! (isa Venus::Check::Error) (see error_on_coded)
5922  
5923 =back
5924  
5925 =cut
5926  
5927 =head2 scalarref
5928  
5929 scalarref(coderef @code) (Venus::Check)
5930  
5931 The scalarref method configures the object to accept scalar references and returns
5932 the invocant.
5933  
5934 I<Since C<3.55>>
5935  
5936 =over 4
5937  
5938 =item scalarref example 1
5939  
5940 # given: synopsis
5941  
5942 package main;
5943  
5944 $check = $check->scalarref;
5945  
5946 # bless(..., 'Venus::Check')
5947  
5948 # my $result = $check->eval(\'');
5949  
5950 # true
5951  
5952 =back
5953  
5954 =over 4
5955  
5956 =item scalarref example 2
5957  
5958 # given: synopsis
5959  
5960 package main;
5961  
5962 $check = $check->scalarref;
5963  
5964 # bless(..., 'Venus::Check')
5965  
5966 # my $result = $check->eval('');
5967  
5968 # false
5969  
5970 =back
5971  
5972 =over 4
5973  
5974 =item scalarref example 3
5975  
5976 # given: synopsis
5977  
5978 package main;
5979  
5980 $check = $check->scalarref;
5981  
5982 # bless(..., 'Venus::Check')
5983  
5984 # my $result = $check->result(\'');
5985  
5986 # \''
5987  
5988 =back
5989  
5990 =over 4
5991  
5992 =item scalarref example 4
5993  
5994 # given: synopsis
5995  
5996 package main;
5997  
5998 $check = $check->scalarref;
5999  
6000 # bless(..., 'Venus::Check')
6001  
6002 # my $result = $check->result('');
6003  
6004 # Exception! (isa Venus::Check::Error) (see error_on_coded)
6005  
6006 =back
6007  
6008 =cut
6009  
6010 =head2 string
6011  
6012 string(coderef @code) (Venus::Check)
6013  
6014 The string method configures the object to accept string values and returns the
6015 invocant.
6016  
6017 I<Since C<3.55>>
6018  
6019 =over 4
6020  
6021 =item string example 1
6022  
6023 # given: synopsis
6024  
6025 package main;
6026  
6027 $check = $check->string;
6028  
6029 # bless(..., 'Venus::Check')
6030  
6031 # my $result = $check->eval('hello');
6032  
6033 # true
6034  
6035 =back
6036  
6037 =over 4
6038  
6039 =item string example 2
6040  
6041 # given: synopsis
6042  
6043 package main;
6044  
6045 $check = $check->string;
6046  
6047 # bless(..., 'Venus::Check')
6048  
6049 # my $result = $check->eval(12345);
6050  
6051 # false
6052  
6053 =back
6054  
6055 =over 4
6056  
6057 =item string example 3
6058  
6059 # given: synopsis
6060  
6061 package main;
6062  
6063 $check = $check->string;
6064  
6065 # bless(..., 'Venus::Check')
6066  
6067 # my $result = $check->result('hello');
6068  
6069 # 'hello'
6070  
6071 =back
6072  
6073 =over 4
6074  
6075 =item string example 4
6076  
6077 # given: synopsis
6078  
6079 package main;
6080  
6081 $check = $check->string;
6082  
6083 # bless(..., 'Venus::Check')
6084  
6085 # my $result = $check->result(12345);
6086  
6087 # Exception! (isa Venus::Check::Error) (see error_on_coded)
6088  
6089 =back
6090  
6091 =cut
6092  
6093 =head2 tuple
6094  
6095 tuple(string | within[arrayref, string] @args) (Venus::Check)
6096  
6097 The tuple method configures the object to accept array references which conform
6098 to a tuple specification, and returns the invocant. The value being evaluated
6099 must contain at-least one element to match.
6100  
6101 I<Since C<3.55>>
6102  
6103 =over 4
6104  
6105 =item tuple example 1
6106  
6107 # given: synopsis
6108  
6109 package main;
6110  
6111 $check = $check->tuple('string', 'number');
6112  
6113 # bless(..., 'Venus::Check')
6114  
6115 # my $result = $check->eval(['hello', 12345]);
6116  
6117 # true
6118  
6119 =back
6120  
6121 =over 4
6122  
6123 =item tuple example 2
6124  
6125 # given: synopsis
6126  
6127 package main;
6128  
6129 $check = $check->tuple('string', 'number');
6130  
6131 # bless(..., 'Venus::Check')
6132  
6133 # my $result = $check->eval([]);
6134  
6135 # false
6136  
6137 =back
6138  
6139 =over 4
6140  
6141 =item tuple example 3
6142  
6143 # given: synopsis
6144  
6145 package main;
6146  
6147 $check = $check->tuple('string', 'number');
6148  
6149 # bless(..., 'Venus::Check')
6150  
6151 # my $result = $check->result(['hello', 12345]);
6152  
6153 # ['hello', 12345]
6154  
6155 =back
6156  
6157 =over 4
6158  
6159 =item tuple example 4
6160  
6161 # given: synopsis
6162  
6163 package main;
6164  
6165 $check = $check->tuple('string', 'number');
6166  
6167 # bless(..., 'Venus::Check')
6168  
6169 # my $result = $check->result(undef);
6170  
6171 # Exception! (isa Venus::Check::Error) (see error_on_defined)
6172  
6173 =back
6174  
6175 =over 4
6176  
6177 =item tuple example 5
6178  
6179 # given: synopsis
6180  
6181 package main;
6182  
6183 $check = $check->tuple('string', 'number');
6184  
6185 # bless(..., 'Venus::Check')
6186  
6187 # my $result = $check->result({});
6188  
6189 # Exception! (isa Venus::Check::Error) (see error_on_arrayref)
6190  
6191 =back
6192  
6193 =over 4
6194  
6195 =item tuple example 6
6196  
6197 # given: synopsis
6198  
6199 package main;
6200  
6201 $check = $check->tuple('string', 'number');
6202  
6203 # bless(..., 'Venus::Check')
6204  
6205 # my $result = $check->result([]);
6206  
6207 # Exception! (isa Venus::Check::Error) (see error_on_arrayref_count)
6208  
6209 =back
6210  
6211 =cut
6212  
6213 =head2 undef
6214  
6215 undef(coderef @code) (Venus::Check)
6216  
6217 The undef method configures the object to accept undefined values and returns
6218 the invocant.
6219  
6220 I<Since C<3.55>>
6221  
6222 =over 4
6223  
6224 =item undef example 1
6225  
6226 # given: synopsis
6227  
6228 package main;
6229  
6230 $check = $check->undef;
6231  
6232 # bless(..., 'Venus::Check')
6233  
6234 # my $result = $check->eval(undef);
6235  
6236 # true
6237  
6238 =back
6239  
6240 =over 4
6241  
6242 =item undef example 2
6243  
6244 # given: synopsis
6245  
6246 package main;
6247  
6248 $check = $check->undef;
6249  
6250 # bless(..., 'Venus::Check')
6251  
6252 # my $result = $check->eval('');
6253  
6254 # false
6255  
6256 =back
6257  
6258 =over 4
6259  
6260 =item undef example 3
6261  
6262 # given: synopsis
6263  
6264 package main;
6265  
6266 $check = $check->undef;
6267  
6268 # bless(..., 'Venus::Check')
6269  
6270 # my $result = $check->result(undef);
6271  
6272 # undef
6273  
6274 =back
6275  
6276 =over 4
6277  
6278 =item undef example 4
6279  
6280 # given: synopsis
6281  
6282 package main;
6283  
6284 $check = $check->undef;
6285  
6286 # bless(..., 'Venus::Check')
6287  
6288 # my $result = $check->result('');
6289  
6290 # Exception! (isa Venus::Check::Error) (see error_on_coded)
6291  
6292 =back
6293  
6294 =cut
6295  
6296 =head2 value
6297  
6298 value(coderef @code) (Venus::Check)
6299  
6300 The value method configures the object to accept defined, non-reference,
6301 values, and returns the invocant.
6302  
6303 I<Since C<3.55>>
6304  
6305 =over 4
6306  
6307 =item value example 1
6308  
6309 # given: synopsis
6310  
6311 package main;
6312  
6313 $check = $check->value;
6314  
6315 # bless(..., 'Venus::Check')
6316  
6317 # my $result = $check->eval(1);
6318  
6319 # true
6320  
6321 =back
6322  
6323 =over 4
6324  
6325 =item value example 2
6326  
6327 # given: synopsis
6328  
6329 package main;
6330  
6331 $check = $check->value;
6332  
6333 # bless(..., 'Venus::Check')
6334  
6335 # my $result = $check->eval({});
6336  
6337 # false
6338  
6339 =back
6340  
6341 =over 4
6342  
6343 =item value example 3
6344  
6345 # given: synopsis
6346  
6347 package main;
6348  
6349 $check = $check->value;
6350  
6351 # bless(..., 'Venus::Check')
6352  
6353 # my $result = $check->result(1);
6354  
6355 # 1
6356  
6357 =back
6358  
6359 =over 4
6360  
6361 =item value example 4
6362  
6363 # given: synopsis
6364  
6365 package main;
6366  
6367 $check = $check->value;
6368  
6369 # bless(..., 'Venus::Check')
6370  
6371 # my $result = $check->result(undef);
6372  
6373 # Exception! (isa Venus::Check::Error) (see error_on_defined)
6374  
6375 =back
6376  
6377 =over 4
6378  
6379 =item value example 5
6380  
6381 # given: synopsis
6382  
6383 package main;
6384  
6385 $check = $check->value;
6386  
6387 # bless(..., 'Venus::Check')
6388  
6389 # my $result = $check->result({});
6390  
6391 # Exception! (isa Venus::Check::Error) (see error_on_value)
6392  
6393 =back
6394  
6395 =cut
6396  
6397 =head2 what
6398  
6399 what(any $data) (string)
6400  
6401 The type method returns the canonical data type name for the value provided.
6402  
6403 I<Since C<3.55>>
6404  
6405 =over 4
6406  
6407 =item what example 1
6408  
6409 # given: synopsis
6410  
6411 package main;
6412  
6413 my $what = $check->what({});
6414  
6415 # 'hashref'
6416  
6417 =back
6418  
6419 =over 4
6420  
6421 =item what example 2
6422  
6423 # given: synopsis
6424  
6425 package main;
6426  
6427 my $what = $check->what([]);
6428  
6429 # 'arrayref'
6430  
6431 =back
6432  
6433 =over 4
6434  
6435 =item what example 3
6436  
6437 # given: synopsis
6438  
6439 package main;
6440  
6441 my $what = $check->what('Venus::Check');
6442  
6443 # 'string'
6444  
6445 =back
6446  
6447 =over 4
6448  
6449 =item what example 4
6450  
6451 # given: synopsis
6452  
6453 package main;
6454  
6455 my $what = $check->what(Venus::Check->new);
6456  
6457 # 'object'
6458  
6459 =back
6460  
6461 =cut
6462  
6463 =head2 within
6464  
6465 within(string $type, string | within[arrayref, string] @args) (Venus::Check)
6466  
6467 The within method configures the object, registering a constraint action as a
6468 sub-match operation, to accept array references, hash references, or mappable
6469 values (see L<Venus::Role::Mappable>), and returns a new L<Venus::Check>
6470 instance for the sub-match operation (not the invocant). This operation can
6471 traverse blessed array or hash based values, or objects derived from classes
6472 which consume the "mappable" role. The value being evaluated must contain
6473 at-least one element to match.
6474  
6475 I<Since C<3.55>>
6476  
6477 =over 4
6478  
6479 =item within example 1
6480  
6481 # given: synopsis
6482  
6483 package main;
6484  
6485 my $within = $check->within('arrayref', 'string');
6486  
6487 # bless(..., 'Venus::Check')
6488  
6489 $check;
6490  
6491 # bless(..., 'Venus::Check')
6492  
6493 # my $result = $check->eval(['hello']);
6494  
6495 # true
6496  
6497 =back
6498  
6499 =over 4
6500  
6501 =item within example 2
6502  
6503 # given: synopsis
6504  
6505 package main;
6506  
6507 my $within = $check->within('arrayref', 'string');
6508  
6509 # bless(..., 'Venus::Check')
6510  
6511 $check;
6512  
6513 # bless(..., 'Venus::Check')
6514  
6515 # my $result = $check->eval([]);
6516  
6517 # false
6518  
6519 =back
6520  
6521 =over 4
6522  
6523 =item within example 3
6524  
6525 # given: synopsis
6526  
6527 package main;
6528  
6529 my $within = $check->within('arrayref', 'string');
6530  
6531 # bless(..., 'Venus::Check')
6532  
6533 $check;
6534  
6535 # bless(..., 'Venus::Check')
6536  
6537 # my $result = $check->result(['hello']);
6538  
6539 # ['hello']
6540  
6541 =back
6542  
6543 =over 4
6544  
6545 =item within example 4
6546  
6547 # given: synopsis
6548  
6549 package main;
6550  
6551 my $within = $check->within('arrayref', 'string');
6552  
6553 # bless(..., 'Venus::Check')
6554  
6555 $check;
6556  
6557 # bless(..., 'Venus::Check')
6558  
6559 # my $result = $check->result(undef);
6560  
6561 # Exception! (isa Venus::Check::Error) (see error_on_defined)
6562  
6563 =back
6564  
6565 =over 4
6566  
6567 =item within example 5
6568  
6569 # given: synopsis
6570  
6571 package main;
6572  
6573 my $within = $check->within('arrayref', 'string');
6574  
6575 # bless(..., 'Venus::Check')
6576  
6577 $check;
6578  
6579 # bless(..., 'Venus::Check')
6580  
6581 # my $result = $check->result({});
6582  
6583 # Exception! (isa Venus::Check::Error) (see error_on_arrayref)
6584  
6585 =back
6586  
6587 =over 4
6588  
6589 =item within example 6
6590  
6591 # given: synopsis
6592  
6593 package main;
6594  
6595 my $within = $check->within('arrayref', 'string');
6596  
6597 # bless(..., 'Venus::Check')
6598  
6599 $check;
6600  
6601 # bless(..., 'Venus::Check')
6602  
6603 # my $result = $check->result([]);
6604  
6605 # Exception! (isa Venus::Check::Error) (see error_on_arrayref_count)
6606  
6607 =back
6608  
6609 =over 4
6610  
6611 =item within example 7
6612  
6613 # given: synopsis
6614  
6615 package main;
6616  
6617 my $within = $check->within('arrayref', 'string');
6618  
6619 # bless(..., 'Venus::Check')
6620  
6621 $check;
6622  
6623 # bless(..., 'Venus::Check')
6624  
6625 # my $result = $check->result([rand]);
6626  
6627 # Exception! (isa Venus::Check::Error) (see error_on_coded)
6628  
6629 =back
6630  
6631 =over 4
6632  
6633 =item within example 8
6634  
6635 # given: synopsis
6636  
6637 package main;
6638  
6639 my $within = $check->within('hashref', 'string');
6640  
6641 # bless(..., 'Venus::Check')
6642  
6643 $check;
6644  
6645 # bless(..., 'Venus::Check')
6646  
6647 # my $result = $check->eval({title => 'hello'});
6648  
6649 # true
6650  
6651 =back
6652  
6653 =over 4
6654  
6655 =item within example 9
6656  
6657 # given: synopsis
6658  
6659 package main;
6660  
6661 my $within = $check->within('hashref', 'string');
6662  
6663 # bless(..., 'Venus::Check')
6664  
6665 $check;
6666  
6667 # bless(..., 'Venus::Check')
6668  
6669 # my $result = $check->eval({});
6670  
6671 # false
6672  
6673 =back
6674  
6675 =over 4
6676  
6677 =item within example 10
6678  
6679 # given: synopsis
6680  
6681 package main;
6682  
6683 my $within = $check->within('hashref', 'string');
6684  
6685 # bless(..., 'Venus::Check')
6686  
6687 $check;
6688  
6689 # bless(..., 'Venus::Check')
6690  
6691 # my $result = $check->result({title => 'hello'});
6692  
6693 # {title => 'hello'}
6694  
6695 =back
6696  
6697 =over 4
6698  
6699 =item within example 11
6700  
6701 # given: synopsis
6702  
6703 package main;
6704  
6705 my $within = $check->within('hashref', 'string');
6706  
6707 # bless(..., 'Venus::Check')
6708  
6709 $check;
6710  
6711 # bless(..., 'Venus::Check')
6712  
6713 # my $result = $check->result(undef);
6714  
6715 # Exception! (isa Venus::Check::Error) (see error_on_defined)
6716  
6717 =back
6718  
6719 =over 4
6720  
6721 =item within example 12
6722  
6723 # given: synopsis
6724  
6725 package main;
6726  
6727 my $within = $check->within('hashref', 'string');
6728  
6729 # bless(..., 'Venus::Check')
6730  
6731 $check;
6732  
6733 # bless(..., 'Venus::Check')
6734  
6735 # my $result = $check->result([]);
6736  
6737 # Exception! (isa Venus::Check::Error) (see error_on_hashref)
6738  
6739 =back
6740  
6741 =over 4
6742  
6743 =item within example 13
6744  
6745 # given: synopsis
6746  
6747 package main;
6748  
6749 my $within = $check->within('hashref', 'string');
6750  
6751 # bless(..., 'Venus::Check')
6752  
6753 $check;
6754  
6755 # bless(..., 'Venus::Check')
6756  
6757 # my $result = $check->result({});
6758  
6759 # Exception! (isa Venus::Check::Error) (see error_on_hashref_empty)
6760  
6761 =back
6762  
6763 =over 4
6764  
6765 =item within example 14
6766  
6767 # given: synopsis
6768  
6769 package main;
6770  
6771 my $within = $check->within('hashref', 'string');
6772  
6773 # bless(..., 'Venus::Check')
6774  
6775 $check;
6776  
6777 # bless(..., 'Venus::Check')
6778  
6779 # my $result = $check->result({title => rand});
6780  
6781 # Exception! (isa Venus::Check::Error) (see error_on_coded)
6782  
6783 =back
6784  
6785 =over 4
6786  
6787 =item within example 15
6788  
6789 # given: synopsis
6790  
6791 package main;
6792  
6793 my $within = $check->within('Venus::Hash', 'string');
6794  
6795 # bless(..., 'Venus::Check')
6796  
6797 $check;
6798  
6799 # bless(..., 'Venus::Check')
6800  
6801 # my $result = $check->result({title => 'engineer'});
6802  
6803 # Exception! (isa Venus::Check::Error) (see error_on_mappable_isa)
6804  
6805 =back
6806  
6807 =over 4
6808  
6809 =item within example 16
6810  
6811 # given: synopsis
6812  
6813 package main;
6814  
6815 use Venus::Hash;
6816  
6817 my $within = $check->within('Venus::Hash', 'string');
6818  
6819 # bless(..., 'Venus::Check')
6820  
6821 $check;
6822  
6823 # bless(..., 'Venus::Check')
6824  
6825 # my $result = $check->result(Venus::Hash->new);
6826  
6827 # Exception! (isa Venus::Check::Error) (see error_on_mappable_empty)
6828  
6829 =back
6830  
6831 =over 4
6832  
6833 =item within example 17
6834  
6835 # given: synopsis
6836  
6837 package main;
6838  
6839 use Venus::Hash;
6840  
6841 my $within = $check->within('Venus::Hash', 'string');
6842  
6843 # bless(..., 'Venus::Check')
6844  
6845 $check;
6846  
6847 # bless(..., 'Venus::Check')
6848  
6849 # my $result = $check->eval(Venus::Hash->new({title => 'engineer'}));
6850  
6851 # true
6852  
6853 =back
6854  
6855 =over 4
6856  
6857 =item B<may raise> L<Venus::Check::Error> C<on.within>
6858  
6859 # given: synopsis;
6860  
6861 $check->within('scalarref', 'string');
6862  
6863 # Error! (on.within)
6864  
6865 =back
6866  
6867 =cut
6868  
6869 =head2 yesno
6870  
6871 yesno(coderef @code) (Venus::Check)
6872  
6873 The yesno method configures the object to accept a string value, that's case
6874 insensitive, and that's either C<"y"> or C<"yes"> or C<1> or C<"n"> or C<"no">
6875 or C<0>, and returns the invocant.
6876  
6877 I<Since C<3.55>>
6878  
6879 =over 4
6880  
6881 =item yesno example 1
6882  
6883 # given: synopsis
6884  
6885 package main;
6886  
6887 $check = $check->yesno;
6888  
6889 # bless(..., 'Venus::Check')
6890  
6891 # my $result = $check->eval('yes');
6892  
6893 # true
6894  
6895 =back
6896  
6897 =over 4
6898  
6899 =item yesno example 2
6900  
6901 # given: synopsis
6902  
6903 package main;
6904  
6905 $check = $check->yesno;
6906  
6907 # bless(..., 'Venus::Check')
6908  
6909 # my $result = $check->eval('yup');
6910  
6911 # false
6912  
6913 =back
6914  
6915 =over 4
6916  
6917 =item yesno example 3
6918  
6919 # given: synopsis
6920  
6921 package main;
6922  
6923 $check = $check->yesno;
6924  
6925 # bless(..., 'Venus::Check')
6926  
6927 # my $result = $check->result('yes');
6928  
6929 # 'yes'
6930  
6931 =back
6932  
6933 =over 4
6934  
6935 =item yesno example 4
6936  
6937 # given: synopsis
6938  
6939 package main;
6940  
6941 $check = $check->yesno;
6942  
6943 # bless(..., 'Venus::Check')
6944  
6945 # my $result = $check->result(undef);
6946  
6947 # Exception! (isa Venus::Check::Error) (see error_on_defined)
6948  
6949 =back
6950  
6951 =over 4
6952  
6953 =item yesno example 5
6954  
6955 # given: synopsis
6956  
6957 package main;
6958  
6959 $check = $check->yesno;
6960  
6961 # bless(..., 'Venus::Check')
6962  
6963 # my $result = $check->result('yup');
6964  
6965 # Exception! (isa Venus::Check::Error) (see error_on_yesno)
6966  
6967 =back
6968  
6969 =cut
6970  
6971 =head1 AUTHORS
6972  
6973 Awncorp, C<awncorp@cpan.org>
6974  
6975 =cut
6976  
6977 =head1 LICENSE
6978  
6979 Copyright (C) 2022, Awncorp, C<awncorp@cpan.org>.
6980  
6981 This program is free software, you can redistribute it and/or modify it under
6982 the terms of the Apache license version 2.0.
6983  
6984 =cut
« blib/lib/Venus/Enum.pm ↑ Summary blib/lib/Venus/Opts.pm »