Brick::Composers - This is the description
use Brick::Constraints::Bucket;
This module defines composing functions in the Brick::Constraints package. Each function takes a list of code refs and returns a single code ref that wraps all of them. The single code ref returns true or false (but defined), as with other constraints.
If a composer cannot create the single code ref (for instance, due to
bad input) it returns undef of the empty list, indicating a failure
in programming rather than a failure of the data to validate.
This is AND with NO short-circuiting.
( A && B && C )
This function creates a new constraint that returns true if all of its
constraints return true. All constraints are checked so there is no
short-circuiting. This allows you to get back all of the errors at
once.
This is OR but with NO short-circuiting.
( A || B || C )
This function creates a new constraint that returns true if all of its
constraints return true. All constraints are checked so there is no
short-circuiting.
( NOT A && NOT B && NOT C )
NOT ( A || B || C )
This function creates a new constraint that returns true if all of its constraints return false. All constraints are checked so there is no short-circuiting.
=cut
| sub __compose_satisfy_none | |
| { | |
| my $bucket = shift; | |
| $bucket->__compose_satisfy_N_to_M( 0, 0, @_ ); | |
| } |
BEGIN { *__none = *__compose_satisfy_none; }
This function creates a new constraint that returns true if exactly N of its constraints return true. All constraints are checked so there is no short-circuiting.
This function creates a new constraint that returns true if between N and M (inclusive) of its constraints return true. All constraints are checked so there is no short-circuiting.
This composers negates the sense of the code ref. If the code ref returns true, this composer makes it false, and vice versa.
Go through the list of closures, trying each one until one suceeds. If a closure doesn't die, but doesn't return true, this doesn't fail but just moves on. Return true for the first one that passes, short-circuited the rest. If none of the closures pass, die with an error noting that nothing passed.
If one of the subs dies, this composer still dies.
This can still die for programming (not logic) errors.
Keep going as long as the closures return true.
The closure that returns undef is a selector.
If a closure doesn't die and doesn't don't fail, just move on. Return true for the first one that passes, short-circuited the rest. If none of the closures pass, die with an error noting that nothing passed.
This can still die for programming (not logic) errors.
$result $@ what action
------------------------------------------------------------
1 undef passed go on to next brick
undef undef selector stop, return undef, no die
failed
undef string program stop, die with string
error
undef ref validator stop, die with ref
failed
TBA
TBA
This source is part of a SourceForge project which always has the latest sources in SVN, as well as all of the previous releases.
svn co https://brian-d-foy.svn.sourceforge.net/svnroot/brian-d-foy brian-d-foy
If, for some reason, I disappear from the world, one of the other members of the project can shepherd this module appropriately.
brian d foy, <bdfoy@cpan.org>
Copyright (c) 2007, brian d foy, All Rights Reserved.
You may redistribute this under the same terms as Perl itself.