1Declare::Constraints::SUismeprleC:o:nDLteircbilrbaaurrteye::d::CGPoeennrseltrraDaloi(cn3ut)mse:n:tSaitmipolne::Library::General(3)
2
3
4

NAME

6       Declare::Constraints::Simple::Library::General - General Constraints
7

SYNOPSIS

9         # custom error messages
10         my $constraint =
11           And( Message( 'You need to specify a Value', IsDefined ),
12                Message( 'The specified Value is not an Int', IsInt ));
13
14         # build results
15         my $valid   = ReturnTrue;
16         my $invalid = ReturnFalse('Just because');
17

DESCRIPTION

19       This library is meant to contain those constraints and constraint-like
20       elements that apply generally to the whole framework.
21

CONSTRAINTS

23       Message($message, $constraint)
24
25       Overrides the "message" set on the result object for failures in $con‐
26       straint. For example:
27
28         my $message = 'How hard is it to give me a number?';
29         my $constraint = Message($message, IsNumber);
30
31         my $result = $constraint->('duh...');
32         print $result->message, "\n";
33
34       The "Message" constraint overrides the error message returned by it's
35       whole subtree, however, the "Message" specification nearest to the
36       point of failure will win. So while this
37
38         my $constraint = Message( 'Foo',
39                                   IsArrayRef( Message( 'Bar', IsInt )));
40
41         my $result = $constraint->(['I am not an Integer']);
42         print $result->message;
43
44       will print "Bar", this
45
46         my $result = $constraint->('I\'m not even an ArrayRef');
47         print $result->message;
48
49       will output "Foo".
50
51       Scope($name, $constraint)
52
53       Executes the passed $constraint in a newly generated scope named $name.
54
55       SetResult($scope, $name, $constraint)
56
57       Stores the result ov an evaluation of $constraint in $scope under
58       $name.
59
60       IsValid($scope, $name)
61
62       Returns a true result if the result $name, which has to have been
63       stored previously in the scope named $scope, was valid.
64
65       ReturnTrue()
66
67       Returns a true result.
68
69       ReturnFalse($msg)
70
71       Returns a false result containing $msg as error message.
72

SEE ALSO

74       Declare::Constraints::Simple, Declare::Constraints::Simple::Library
75

AUTHOR

77       Robert 'phaylon' Sedlacek "<phaylon@dunkelheit.at>"
78
80       This module is free software, you can redistribute it and/or modify it
81       under the same terms as perl itself.
82
83
84
85perl v5.8.8                  Decla2r0e0:6:-C0o9n-s1t1raints::Simple::Library::General(3)
Impressum