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

SEE ALSO

76       Declare::Constraints::Simple, Declare::Constraints::Simple::Library
77

AUTHOR

79       Robert 'phaylon' Sedlacek "<phaylon@dunkelheit.at>"
80
82       This module is free software, you can redistribute it and/or modify it
83       under the same terms as perl itself.
84
85
86
87perl v5.8.8              Declare::2C0o0n6s-t0r9a-i1n1ts::Simple::Library::Referencial(3)
Impressum