.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Declare::Constraints::Simple::Library::General 3pm" .TH Declare::Constraints::Simple::Library::General 3pm "2021-01-09" "perl v5.32.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Declare::Constraints::Simple::Library::General \- General Constraints .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 4 \& # custom error messages \& my $constraint = \& And( Message( \*(AqYou need to specify a Value\*(Aq, IsDefined ), \& Message( \*(AqThe specified Value is not an Int\*(Aq, IsInt )); \& \& # build results \& my $valid = ReturnTrue; \& my $invalid = ReturnFalse(\*(AqJust because\*(Aq); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This library is meant to contain those constraints and constraint-like elements that apply generally to the whole framework. .SH "CONSTRAINTS" .IX Header "CONSTRAINTS" .ie n .SS "Message($message, $constraint)" .el .SS "Message($message, \f(CW$constraint\fP)" .IX Subsection "Message($message, $constraint)" Overrides the \f(CW\*(C`message\*(C'\fR set on the result object for failures in \&\f(CW$constraint\fR. For example: .PP .Vb 2 \& my $message = \*(AqHow hard is it to give me a number?\*(Aq; \& my $constraint = Message($message, IsNumber); \& \& my $result = $constraint\->(\*(Aqduh...\*(Aq); \& print $result\->message, "\en"; .Ve .PP The \f(CW\*(C`Message\*(C'\fR constraint overrides the error message returned by it's whole subtree, however, the \f(CW\*(C`Message\*(C'\fR specification nearest to the point of failure will win. So while this .PP .Vb 2 \& my $constraint = Message( \*(AqFoo\*(Aq, \& IsArrayRef( Message( \*(AqBar\*(Aq, IsInt ))); \& \& my $result = $constraint\->([\*(AqI am not an Integer\*(Aq]); \& print $result\->message; .Ve .PP will print \f(CW\*(C`Bar\*(C'\fR, this .PP .Vb 2 \& my $result = $constraint\->(\*(AqI\e\*(Aqm not even an ArrayRef\*(Aq); \& print $result\->message; .Ve .PP will output \f(CW\*(C`Foo\*(C'\fR. .ie n .SS "Scope($name, $constraint)" .el .SS "Scope($name, \f(CW$constraint\fP)" .IX Subsection "Scope($name, $constraint)" Executes the passed \f(CW$constraint\fR in a newly generated scope named \&\f(CW$name\fR. .ie n .SS "SetResult($scope, $name, $constraint)" .el .SS "SetResult($scope, \f(CW$name\fP, \f(CW$constraint\fP)" .IX Subsection "SetResult($scope, $name, $constraint)" Stores the result ov an evaluation of \f(CW$constraint\fR in \f(CW$scope\fR under \&\f(CW$name\fR. .ie n .SS "IsValid($scope, $name)" .el .SS "IsValid($scope, \f(CW$name\fP)" .IX Subsection "IsValid($scope, $name)" Returns a true result if the result \f(CW$name\fR, which has to have been stored previously in the scope named \f(CW$scope\fR, was valid. .SS "\fBReturnTrue()\fP" .IX Subsection "ReturnTrue()" Returns a true result. .SS "ReturnFalse($msg)" .IX Subsection "ReturnFalse($msg)" Returns a false result containing \f(CW$msg\fR as error message. .SH "SEE ALSO" .IX Header "SEE ALSO" Declare::Constraints::Simple, Declare::Constraints::Simple::Library .SH "AUTHOR" .IX Header "AUTHOR" Robert 'phaylon' Sedlacek \f(CW\*(C`\*(C'\fR .SH "LICENSE AND COPYRIGHT" .IX Header "LICENSE AND COPYRIGHT" This module is free software, you can redistribute it and/or modify it under the same terms as perl itself.