ILIAS
trunk Revision v11.0_alpha-2638-g80c1d007f79
|
A constraint encodes some resrtictions on values. More...
Public Member Functions | |
check ($value) | |
Checks the provided value. More... | |
accepts ($value) | |
Tells if the provided value complies. More... | |
problemWith ($value) | |
Tells what the problem with the provided value is. More... | |
applyTo (Result $result) | |
Restricts a Result. More... | |
withProblemBuilder (callable $builder) | |
Get a constraint like this one with a builder for a custom error message. More... | |
![]() | |
transform ($from) | |
Perform the transformation. More... | |
__invoke ($from) | |
Transformations should be callable. More... | |
A constraint encodes some resrtictions on values.
Constraints MUST NOT modify the supplied value.
Definition at line 31 of file Constraint.php.
ILIAS\Refinery\Constraint::accepts | ( | $value | ) |
Tells if the provided value complies.
mixed | $value |
Implemented in ILIAS\Refinery\To\Transformation\RecordTransformation, ILIAS\Refinery\To\Transformation\TupleTransformation, ILIAS\AdvancedMetaData\Services\ObjectModes\Custom\Custom\Constraint, ILIAS\Refinery\To\Transformation\DictionaryTransformation, ILIAS\Refinery\To\Transformation\ListTransformation, ILIAS\Refinery\To\Transformation\DateTimeTransformation, ILIAS\Refinery\To\Transformation\BooleanTransformation, ILIAS\Refinery\To\Transformation\FloatTransformation, ILIAS\Refinery\To\Transformation\IntegerTransformation, ILIAS\Refinery\To\Transformation\StringTransformation, ILIAS\Refinery\To\Transformation\InArrayTransformation, and ILIAS\Refinery\IsExecutableTransformation.
Referenced by ILIAS\Refinery\Logical\Not\__construct(), LogicalOrTest\testAccept(), and PasswordContraintsTest\testAccept().
ILIAS\Refinery\Constraint::applyTo | ( | Result | $result | ) |
Restricts a Result.
Must do nothing with the result if $result->isError(). Must replace the result with an error according to problemWith() if !accepts($result->value()).
Result | $result |
Implements ILIAS\Refinery\Transformation.
Implemented in ILIAS\AdvancedMetaData\Services\ObjectModes\Custom\Custom\Constraint.
Referenced by LogicalOrTest\testRestrict().
ILIAS\Refinery\Constraint::check | ( | $value | ) |
Checks the provided value.
Should not throw if accepts($value).
mixed | $value |
UnexpectedValueException | if value does not comply with encoded constraint. |
Implemented in ILIAS\Refinery\To\Transformation\RecordTransformation, ILIAS\Refinery\To\Transformation\TupleTransformation, ILIAS\AdvancedMetaData\Services\ObjectModes\Custom\Custom\Constraint, ILIAS\Refinery\To\Transformation\DictionaryTransformation, ILIAS\Refinery\To\Transformation\ListTransformation, ILIAS\Refinery\To\Transformation\DateTimeTransformation, ILIAS\Refinery\To\Transformation\BooleanTransformation, ILIAS\Refinery\To\Transformation\FloatTransformation, ILIAS\Refinery\To\Transformation\IntegerTransformation, and ILIAS\Refinery\To\Transformation\StringTransformation.
Referenced by LogicalOrTest\testCheck().
ILIAS\Refinery\Constraint::problemWith | ( | $value | ) |
Tells what the problem with the provided value is.
Should return null if accepts($value).
mixed | $value |
Implemented in ILIAS\Refinery\To\Transformation\RecordTransformation, ILIAS\Refinery\To\Transformation\TupleTransformation, ILIAS\Refinery\To\Transformation\DictionaryTransformation, ILIAS\AdvancedMetaData\Services\ObjectModes\Custom\Custom\Constraint, ILIAS\Refinery\To\Transformation\ListTransformation, ILIAS\Refinery\To\Transformation\DateTimeTransformation, ILIAS\Refinery\To\Transformation\BooleanTransformation, ILIAS\Refinery\To\Transformation\FloatTransformation, ILIAS\Refinery\To\Transformation\IntegerTransformation, and ILIAS\Refinery\To\Transformation\StringTransformation.
Referenced by LogicalOrTest\testProblemWith().
ILIAS\Refinery\Constraint::withProblemBuilder | ( | callable | $builder | ) |
Get a constraint like this one with a builder for a custom error message.
problemWith() must return an error message according to the new builder for the new constraint.
The builder needs to be callable that takes two parameters:
callable | $builder |
Referenced by LogicalOrTest\testWithProblemBuilder().