/** * @param mixed $value * @throws AssertionFailed * @throws \Exception */ public function guardValue($value) { if ($this->required) { Assertion::notNull($value, sprintf('Field [%s] is required and cannot be null.', $this->name)); } if (null !== $value) { $this->type->guard($value, $this); } if (null !== $this->assertion) { call_user_func($this->assertion, $value, $this); } }