Declare::Constraints::Simple::Library::General - General Constraints
# custom error messages my $constraint = And( Message( 'You need to specify a Value', IsDefined ), Message( 'The specified Value is not an Int', IsInt )); # build results my $valid = ReturnTrue; my $invalid = ReturnFalse('Just because');
This library is meant to contain those constraints and constraint-like elements that apply generally to the whole framework.
message set on the result object for failures in
$constraint. For example:
my $message = 'How hard is it to give me a number?'; my $constraint = Message($message, IsNumber); my $result = $constraint->('duh...'); print $result->message, "\n";
Message constraint overrides the error message returned by it's whole subtree, however, the
Message specification nearest to the point of failure will win. So while this
my $constraint = Message( 'Foo', IsArrayRef( Message( 'Bar', IsInt ))); my $result = $constraint->(['I am not an Integer']); print $result->message;
my $result = $constraint->('I\'m not even an ArrayRef'); print $result->message;
Executes the passed
$constraint in a newly generated scope named
Stores the result ov an evaluation of
Returns a true result if the result
$name, which has to have been stored previously in the scope named
$scope, was valid.
Returns a true result.
Returns a false result containing
$msg as error message.
Robert 'phaylon' Sedlacek
This module is free software, you can redistribute it and/or modify it under the same terms as perl itself.