static function spec() { $spec = parent::spec(); unset($spec['props']); unset($spec['rules']); return array_merge($spec, ['class' => ['required' => true, 'kind' => 'string'], 'parser' => ['type' => 'dep', 'kind' => \Nope\Parser::class], 'registry' => ['type' => 'dep', 'kind' => \Fulfil\Registry::class, 'required' => true]]); }
function __construct(...$args) { parent::__construct(...$args); if ($this->trueValues || $this->falseValues) { $this->allowLoose = true; } if ($this->trueValues) { foreach ($this->trueValues as &$value) { if (is_string($value)) { $value = mb_strtolower(\Normalizer::normalize($value)); } elseif (!is_scalar($value)) { throw new \InvalidArgumentException(); } } unset($value); } if ($this->falseValues) { foreach ($this->falseValues as &$value) { if (is_string($value)) { $value = mb_strtolower(\Normalizer::normalize($value)); } elseif (!is_scalar($value)) { throw new \InvalidArgumentException(); } } unset($value); } }
public function __construct(...$args) { parent::__construct(...$args); if ($this->casing && !in_array($this->casing, self::$validCasing)) { throw new \InvalidArgumentException("Casing must be one of " . implode(', ', self::$validCasing)); } }
function __construct(...$args) { parent::__construct(...$args); if ($this->divisibleBy !== null) { $this->divisibleBy = BigNumbers\Decimal::create($this->divisibleBy); if (!$this->divisibleBy->isPositive()) { throw new \InvalidArgumentException("divisibleBy must be a positive integer"); } } }
function __construct(...$args) { parent::__construct(...$args); if ($this->min !== null && $this->max !== null && $this->min > $this->max) { throw new \InvalidArgumentException(); } if ($this->divisibleBy !== null && $this->divisibleBy <= 0) { throw new \InvalidArgumentException("divisibleBy must be a positive integer"); } }
public function __construct(...$args) { parent::__construct(...$args); if (!is_array($this->formats)) { $this->formats = [$this->formats]; } if (is_string($this->tz)) { $this->tz = new \DateTimeZone($this->tz); } }
function __construct(...$args) { parent::__construct(...$args); if ($this->min !== null && is_string($this->min)) { $this->min = \DateTime::createFromFormat(\DateTime::ISO8601, $this->min); } if ($this->max !== null && is_string($this->max)) { $this->max = \DateTime::createFromFormat(\DateTime::ISO8601, $this->max); } }
function initial() { if ($initial = parent::initial()) { return $initial; } foreach ($this->checks as $check) { if ($initial = $check->initial()) { return $initial; } } }
function export() { $out = parent::export(); schemas: foreach ($out['schemas'] as &$v) { $v = $v->export(); } rules: foreach ($this->rules as $k => $rule) { $out['rules'][$k] = $rule->export(); } return $out; }
/** * When multiple checks are present, the first one to return a non-null * initial value is applied. */ function initial() { $initial = parent::initial(); if ($initial === null) { $initial = []; foreach ($this->props as $prop => $checks) { if ($checks === true) { goto next_prop; } foreach ($checks as $c) { $pInitial = $c->initial(); if ($pInitial !== null) { $initial[$prop] = $pInitial; goto next_prop; } } $initial[$prop] = null; next_prop: } } return $initial; }
static function spec() { return array_merge(parent::spec(), ['min' => ['kind' => 'numeric'], 'max' => ['kind' => 'numeric'], 'divisibleBy' => ['kind' => 'numeric'], 'allowString' => ['kind' => 'bool', 'default' => false], 'allowInt' => ['kind' => 'bool', 'default' => true]]); }
static function spec() { return array_merge(parent::spec(), ['class' => ['kind' => 'string', 'required' => true]]); }
static function spec() { return array_merge(parent::spec(), ['emptyMode' => ['setter' => 'setEmptyMode'], 'lengthMin' => ['kind' => 'int'], 'lengthMax' => ['kind' => 'int'], 'length' => ['kind' => 'int'], 'bytesMax' => ['kind' => 'int'], 'pattern' => true]); }
static function spec() { return array_merge(parent::spec(), ['length' => ['kind' => 'int'], 'lengthMin' => ['kind' => 'int'], 'lengthMax' => ['kind' => 'int'], 'unique' => ['kind' => 'bool']]); }