1Declare::Constraints::SUismeprDleeCc:ol:naLtrirebi:rb:auCrtoyen:ds:tRPreeafrielnrteDsno:cc:iuSamilem(np3tl)aet:i:oLnibrary::Referencial(3)
2
3
4

NAME

6       Declare::Constraints::Simple::Library::Referencial - Ref Constraints
7

SYNOPSIS

9         # scalar or array references
10         my $scalar_or_array = IsRefType( qw(SCALAR ARRAY) );
11
12         # scalar reference
13         my $int_ref = IsScalarRef( IsInt );
14
15         # accept mappings of ids to objects with "name" methods
16         my $id_obj_map =
17           IsHashRef( -keys   => IsInt,
18                      -values => And( IsObject,
19                                      HasMethods('name') ));
20
21         # an integer list
22         my $int_list = IsArrayRef( IsInt );
23
24         # accept code references
25         my $is_closure = IsCodeRef;
26
27         # accept a regular expression
28         my $is_regex = IsRegex;
29

DESCRIPTION

31       This library contains those constraints that can test the validity of
32       references and their types.
33

CONSTRAINTS

35   IsRefType(@types)
36       Valid if the value is a reference of a kind in @types.
37
38   IsScalarRef($constraint)
39       This is true if the value is a scalar reference. A possible constraint
40       for the scalar references target value can be passed. E.g.
41
42         my $test_integer_ref = IsScalarRef(IsInt);
43
44   IsArrayRef($constraint)
45       The value is valid if the value is an array reference. The contents of
46       the array can be validated by passing an other $constraint as argument.
47
48       The stack or path part of "IsArrayRef" is "IsArrayRef[$index]" where
49       $index is the index of the failing element.
50
51   IsHashRef(-keys => $constraint, -values => $constraint)
52       True if the value is a hash reference. It can also take two named
53       parameters: "-keys" can pass a constraint to check the hashes keys,
54       "-values" does the same for its values.
55
56       The stack or path part of "IsHashRef" looks like "IsHashRef[$type
57       $key]" where $type is either "val" or "key" depending on what was
58       validated, and $key being the key that didn't pass validation.
59
60   IsCodeRef()
61       Code references have to be valid to pass this constraint.
62
63   IsRegex()
64       True if the value is a regular expression built with "qr". Note
65       however, that a simple string that could be used like "/$rx/" will not
66       pass this constraint. You can combine multiple constraints with
67       And(@constraints) though.
68

SEE ALSO

70       Declare::Constraints::Simple, Declare::Constraints::Simple::Library
71

AUTHOR

73       Robert 'phaylon' Sedlacek "<phaylon@dunkelheit.at>"
74
76       This module is free software, you can redistribute it and/or modify it
77       under the same terms as perl itself.
78
79
80
81perl v5.12.0             Declare::2C0o0n6s-t0r9a-i1n1ts::Simple::Library::Referencial(3)
Impressum