ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ILIAS\Validation\Constraints\LogicalOr Class Reference
+ Inheritance diagram for ILIAS\Validation\Constraints\LogicalOr:
+ Collaboration diagram for ILIAS\Validation\Constraints\LogicalOr:

Public Member Functions

 __construct (array $other, Data\Factory $data_factory, \ilLanguage $lng)
 LogicalOr constructor. More...
 
- Public Member Functions inherited from ILIAS\Validation\Constraints\Custom
 __construct (callable $is_ok, $error, Data\Factory $data_factory, \ilLanguage $lng)
 If $error is a callable it needs to take two parameters: More...
 
 check ($value)
 Checks the provided value.Should not throw if accepts($value).
Exceptions
More...
 
 accepts ($value)
 Tells if the provided value complies.
Parameters
mixed$value
Returns
bool
More...
 
 problemWith ($value)
 Tells what the problem with the provided value is.Should return null if accepts($value).
Parameters
mixed$value
Returns
string|null
More...
 
 restrict (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()).
Parameters
Result$result
Returns
Result
More...
 
 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:
Parameters
callable$builder
Returns
Constraint
More...
 
 getErrorMessage ($value)
 Get the problem message. More...
 

Protected Attributes

 $other = []
 
- Protected Attributes inherited from ILIAS\Validation\Constraints\Custom
 $data_factory
 
 $lng
 
 $is_ok
 
 $error
 

Additional Inherited Members

- Protected Member Functions inherited from ILIAS\Validation\Constraints\Custom
 getLngClosure ()
 Get the closure to be passed to the error-function that does i18n and sprintf. More...
 

Detailed Description

Definition at line 14 of file LogicalOr.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Validation\Constraints\LogicalOr::__construct ( array  $other,
Data\Factory  $data_factory,
\ilLanguage  $lng 
)

LogicalOr constructor.

Parameters
Constraint[]$other
Data\Factory$data_factory

Definition at line 26 of file LogicalOr.php.

References ILIAS\Validation\Constraints\Custom\$data_factory, ILIAS\Validation\Constraints\Custom\$lng, and ILIAS\Validation\Constraints\LogicalOr\$other.

27  {
28  $this->other = $other;
29 
30  parent::__construct(
31  function ($value) {
32  foreach ($this->other as $constraint) {
33  if ($constraint->accepts($value)) {
34  return true;
35  }
36  }
37 
38  return false;
39  },
40  function ($value) {
41  $problems = [];
42 
43  foreach ($this->other as $constraint) {
44  $problems[] = (string) $constraint->problemWith($value);
45  }
46 
47  return 'Please fix one of these: ' . implode(', ', array_filter($problems));
48  },
50  $lng
51  );
52  }

Field Documentation

◆ $other

ILIAS\Validation\Constraints\LogicalOr::$other = []
protected

Definition at line 19 of file LogicalOr.php.

Referenced by ILIAS\Validation\Constraints\LogicalOr\__construct().


The documentation for this class was generated from the following file: