Esempio n. 1
0
 /**
  * ArrayList constructor.
  *
  * @param Type[]|null $arrayMemberType , if it's not null, every element  will be required and validated for type
  */
 public function __construct(array $arrayMemberType = null)
 {
     $description = [];
     foreach ($arrayMemberType as $key => $value) {
         $description[$key] = $value->getTypeDescription();
     }
     parent::__construct(new TypeDescription("Object", ["properties" => $description]), false);
     $this->childrenType = $arrayMemberType;
 }
Esempio n. 2
0
 /**
  * String length properties matching deliberately, You can check string length with regex.
  * Length regex : /^.{8,10}$/ // matches any string between 8 and 10 characters
  * Or: /^.{8,10}$/s matches any string between 8 and 10 characters, including new line characters
  * Text constructor.
  * @param null|string $validatorRegex
  */
 public function __construct($validatorRegex = null)
 {
     $accepted = [];
     if ($validatorRegex) {
         $accepted[static::$propertyPrefix . 'regex'] = $validatorRegex;
     }
     parent::__construct(new TypeDescription("Text", $accepted));
     $this->validatorRegex = $validatorRegex;
 }
Esempio n. 3
0
 /**
  * Union constructor.
  *
  * @param Type[] $acceptedTypes
  */
 public function __construct(array $acceptedTypes)
 {
     $i = 0;
     $description = [];
     foreach ($acceptedTypes as $value) {
         $description[static::$propertyPrefix . "type_" . $i++] = $value;
     }
     $this->types = $acceptedTypes;
     parent::__construct(new TypeDescription("Union", $description), false);
 }
Esempio n. 4
0
 /**
  * Number constructor.
  * Can be used to check if a value is number, and in range, even if it's in a string
  *
  * @param number $minimumValue inclusive minimum value for the variable, not checked if null
  * @param number $maximumValue inclusive maximum value for the variable, not checked if null
  */
 public function __construct($minimumValue = null, $maximumValue = null)
 {
     $description = [];
     if ($minimumValue !== null) {
         $description[static::$propertyPrefix . 'minimum'] = $minimumValue;
     }
     if ($maximumValue !== null) {
         $description[static::$propertyPrefix . 'maximum'] = $maximumValue;
     }
     parent::__construct(new TypeDescription($this->typeName, $description), false);
     $this->min = $minimumValue;
     $this->max = $maximumValue;
 }
Esempio n. 5
0
 public function __construct()
 {
     parent::__construct(new TypeDescription("Boolean"), false);
 }