Example #1
0
 /**
  * {@inheritDoc}
  */
 protected function validateType($value)
 {
     if (!is_scalar($value) && null !== $value) {
         $ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected scalar, but got %s.', $this->getPath(), gettype($value)));
         $ex->setPath($this->getPath());
         throw $ex;
     }
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 protected function validateType($value)
 {
     if (!is_bool($value)) {
         $ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected boolean, but got %s.', $this->getPath(), gettype($value)));
         $ex->setPath($this->getPath());
         throw $ex;
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function validateType($value)
 {
     if (!is_array($value)) {
         $ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected array, but got %s', $this->getPath(), gettype($value)));
         if ($hint = $this->getInfo()) {
             $ex->addHint($hint);
         }
         $ex->setPath($this->getPath());
         throw $ex;
     }
 }
 /**
  * Validates the type of a Node.
  *
  * @param mixed $value The value to validate
  *
  * @throws InvalidTypeException when the value is invalid
  */
 protected function validateType($value)
 {
     if (!$value instanceof Closure && $value !== null) {
         $exception = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected closure, but got %s.', $this->getPath(), gettype($value)));
         if ($hint = $this->getInfo()) {
             $exception->addHint($hint);
         }
         $exception->setPath($this->getPath());
         throw $exception;
     }
 }
Example #5
0
 /**
  * {@inheritdoc}
  */
 protected function validateType($value)
 {
     // Integers are also accepted, we just cast them
     if (is_int($value)) {
         $value = (double) $value;
     }
     if (!is_float($value)) {
         $ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected float, but got %s.', $this->getPath(), gettype($value)));
         $ex->setPath($this->getPath());
         throw $ex;
     }
 }
Example #6
0
 protected function validateType($value)
 {
     if (is_int($value)) {
         $value = (double) $value;
     }
     if (!is_float($value)) {
         $ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected float, but got %s.', $this->getPath(), gettype($value)));
         if ($hint = $this->getInfo()) {
             $ex->addHint($hint);
         }
         $ex->setPath($this->getPath());
         throw $ex;
     }
 }
Example #7
0
 /**
  * Validates the type of the value.
  *
  * @param mixed $value
  *
  * @throws InvalidTypeException
  */
 protected function validateType($value)
 {
     if (!is_array($value) && (!$this->allowFalse || false !== $value)) {
         $ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected array, but got %s', $this->getPath(), gettype($value)));
         $ex->setPath($this->getPath());
         throw $ex;
     }
 }