ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ILIAS\Validation\Factory Class Reference

Factory for creating constraints. More...

+ Collaboration diagram for ILIAS\Validation\Factory:

Public Member Functions

 __construct (Data\Factory $data_factory)
 
 sequential (array $others)
 Get a constraint that sequentially checks the supplied constraints. More...
 
 parallel (array $others)
 Get a constraint that checks the supplied constraints in parallel. More...
 
 not (Constraint $other)
 Get a negated constraint. More...
 
 isInt ()
 Get a constraint for an integer. More...
 
 greaterThan ($min)
 Get the constraint that some value is larger than $min. More...
 
 lessThan ($max)
 Get the constraint that some value is smaller then $max. More...
 
 custom (callable $is_ok, $error)
 Get a custom constraint. More...
 

Protected Attributes

 $data_factory
 

Detailed Description

Factory for creating constraints.

Definition at line 12 of file Factory.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Validation\Factory::__construct ( Data\Factory  $data_factory)

Definition at line 19 of file Factory.php.

20  {
21  $this->data_factory = $data_factory;
22  }

Member Function Documentation

◆ custom()

ILIAS\Validation\Factory::custom ( callable  $is_ok,
  $error 
)

Get a custom constraint.

If the provided value !$is_ok will either use the $error (if it is a string) or provide the value to the $error callback.

Parameters
callable$is_okMUST return boolean
string | callable$error
Returns
Constraint

Definition at line 108 of file Factory.php.

References $error.

109  {
110  return new Constraints\Custom($is_ok, $error, $this->data_factory);
111  }
$error
Definition: Error.php:17

◆ greaterThan()

ILIAS\Validation\Factory::greaterThan (   $min)

Get the constraint that some value is larger than $min.

Parameters
int$min
Returns
Constraint

Definition at line 82 of file Factory.php.

83  {
84  return new Constraints\GreaterThan($min, $this->data_factory);
85  }

◆ isInt()

ILIAS\Validation\Factory::isInt ( )

Get a constraint for an integer.

Returns
Constraint

Definition at line 71 of file Factory.php.

72  {
73  return new Constraints\IsInt($this->data_factory);
74  }

◆ lessThan()

ILIAS\Validation\Factory::lessThan (   $max)

Get the constraint that some value is smaller then $max.

Parameters
int$max
Returns
Constraint

Definition at line 93 of file Factory.php.

94  {
95  return new Constraints\LessThan($max, $this->data_factory);
96  }

◆ not()

ILIAS\Validation\Factory::not ( Constraint  $other)

Get a negated constraint.

Parameters
Constraint$other
Returns
Constraint

Definition at line 59 of file Factory.php.

60  {
61  return new Constraints\Not($other, $this->data_factory);
62  }

◆ parallel()

ILIAS\Validation\Factory::parallel ( array  $others)

Get a constraint that checks the supplied constraints in parallel.

The new constraint tells the problems of all violated constraints.

Parameters
Constraint[]$others
Returns
Constraint

Definition at line 48 of file Factory.php.

49  {
50  return new Constraints\Parallel($others, $this->data_factory);
51  }

◆ sequential()

ILIAS\Validation\Factory::sequential ( array  $others)

Get a constraint that sequentially checks the supplied constraints.

The new constraint tells the problem of the first violated constraint.

Parameters
Constraint[]$others
Returns
Constraint

Definition at line 35 of file Factory.php.

36  {
37  return new Constraints\Sequential($others, $this->data_factory);
38  }

Field Documentation

◆ $data_factory

ILIAS\Validation\Factory::$data_factory
protected

Definition at line 17 of file Factory.php.


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