ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Factory.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 2017 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
3 /* Copyright (c) 2017 Stefan Hecken <stefan.hecken@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4 
5 namespace ILIAS\Validation;
6 
7 use ILIAS\Data;
8 
12 class Factory
13 {
17  protected $data_factory;
18 
19  public function __construct(Data\Factory $data_factory)
20  {
21  $this->data_factory = $data_factory;
22  }
23 
24 
25  // COMBINATORS
26 
35  public function sequential(array $others)
36  {
37  return new Constraints\Sequential($others, $this->data_factory);
38  }
39 
48  public function parallel(array $others)
49  {
50  return new Constraints\Parallel($others, $this->data_factory);
51  }
52 
59  public function not(Constraint $other)
60  {
61  return new Constraints\Not($other, $this->data_factory);
62  }
63 
64  // SOME RESTRICTOINS
65 
71  public function isInt()
72  {
73  return new Constraints\IsInt($this->data_factory);
74  }
75 
82  public function greaterThan($min)
83  {
84  return new Constraints\GreaterThan($min, $this->data_factory);
85  }
86 
93  public function lessThan($max)
94  {
95  return new Constraints\LessThan($max, $this->data_factory);
96  }
97 
108  public function custom(callable $is_ok, $error)
109  {
110  return new Constraints\Custom($is_ok, $error, $this->data_factory);
111  }
112 }
isInt()
Get a constraint for an integer.
Definition: Factory.php:71
A constraint encodes some resrtictions on values.
Definition: Constraint.php:14
custom(callable $is_ok, $error)
Get a custom constraint.
Definition: Factory.php:108
__construct(Data\Factory $data_factory)
Definition: Factory.php:19
$error
Definition: Error.php:17
Builds data types.
Definition: Factory.php:14
Create styles array
The data for the language used.
greaterThan($min)
Get the constraint that some value is larger than $min.
Definition: Factory.php:82
lessThan($max)
Get the constraint that some value is smaller then $max.
Definition: Factory.php:93
not(Constraint $other)
Get a negated constraint.
Definition: Factory.php:59
parallel(array $others)
Get a constraint that checks the supplied constraints in parallel.
Definition: Factory.php:48
sequential(array $others)
Get a constraint that sequentially checks the supplied constraints.
Definition: Factory.php:35