/** * Perform validation against given value * * @param $value * * @throws ValidationException * @return $this */ protected function validate(&$value) { if ($this->str($value)->contains(',')) { $value = $this->str($value)->replace(',', '.')->val(); } $value = floatval($value); if (!$this->isNumber($value)) { $this->expected('number', gettype($value)); } parent::validate($value); return $this; }
/** * Perform validation against given value * * @param $value * * @throws ValidationException * @return $this */ protected function validate(&$value) { if ($this->isString($value) && $this->isNumber($value)) { if (!$this->str($value)->contains('.') && !$this->str($value)->contains(',')) { $value = intval($value); } } if (!$this->isInteger($value)) { $this->expected('integer', gettype($value)); } parent::validate($value); return $this; }
/** * Perform validation against given value * * @param $value * * @throws ValidationException * @return $this */ protected function validate(&$value) { if ($value instanceof AbstractEntity) { $value = $value->id; } if ($value != null && !$this->isString($value) && !$this->isNumber($value)) { $this->expected('string, number or AbstractEntity', gettype($value)); } // Make sure it's a string even if it is a number (convert to numeric string) $value = '' . $value; parent::validate($value); return $this; }
/** * Perform validation against given value * * @param $value * * @return $this * @throws ValidationException */ protected function validate(&$value) { if ($this->isNull($value)) { return $this; } if (!$this->isArray($value) && !$this->isArrayObject($value)) { $this->expected('array or ArrayObject', gettype($value)); } // Call parent method parent::validate($value); // Validate array keys $this->validateNestedKeys($value); return $this; }
/** * Perform validation against given value * * @param $value * * @return $this */ protected function validate(&$value) { $value = StdObjectWrapper::toBool($value); parent::validate($value); return $this; }