1Declare::Constraints::SUismeprleC:o:nLtDirebicrblauartryee:d:::SPCceoarnllsatrDr(oa3ci)unmtesn:t:aStiimopnle::Library::Scalar(3)
2
3
4
6 Declare::Constraints::Simple::Library::Scalar - Scalar Constraints
7
9 # match one of a set of regexes
10 my $some_regexes = Matches(qr/foo/, qr/bar/);
11
12 # allow only defined values
13 my $is_defined = IsDefined;
14
15 # between 5 and 50 chars
16 my $five_to_fifty = HasLength(5, 50);
17
18 # match against a set of values
19 my $command_constraint = IsOneOf(qw(create update delete));
20
21 # check for trueness
22 my $is_true = IsTrue;
23
24 # simple equality
25 my $is_foo = IsEq('foo');
26
28 This library contains all constraints to validate scalar values.
29
31 Matches(@regex)
32 my $c = Matches(qr/foo/, qr/bar/);
33
34 If one of the parameters matches the expression, this is true.
35
36 IsDefined()
37 True if the value is defined.
38
39 HasLength([$min, [$max]])
40 Is true if the value has a length above $min (which defaults to 1> and,
41 if supplied, under the value of $max. A simple
42
43 my $c = HasLength;
44
45 checks if the value has a length of at least 1.
46
47 IsOneOf(@values)
48 True if one of the @values equals the passed value. "undef" values work
49 with this too, so
50
51 my $c = IsOneOf(1, 2, undef);
52
53 will return true on an undefined value.
54
55 IsTrue()
56 True if the value evulates to true in boolean context.
57
58 IsEq($comparator)
59 Valid if the value is "eq" the $comparator.
60
62 Declare::Constraints::Simple, Declare::Constraints::Simple::Library
63
65 Robert 'phaylon' Sedlacek "<phaylon@dunkelheit.at>"
66
68 This module is free software, you can redistribute it and/or modify it
69 under the same terms as perl itself.
70
71
72
73perl v5.34.0 Decl2a0r2e1:-:0C7o-n2s2traints::Simple::Library::Scalar(3)