Esempio n. 1
0
 protected function finalizeValue($value)
 {
     $value = parent::finalizeValue($value);
     if (!in_array($value, $this->values, true)) {
         $ex = new InvalidConfigurationException(sprintf('The value %s is not allowed for path "%s". Permissible values: %s', json_encode($value), $this->getPath(), implode(', ', array_map('json_encode', $this->values))));
         $ex->setPath($this->getPath());
         throw $ex;
     }
     return $value;
 }
Esempio n. 2
0
 /**
  * {@inheritdoc}
  */
 protected function finalizeValue($value)
 {
     $value = parent::finalizeValue($value);
     $errorMsg = null;
     if (isset($this->min) && $value < $this->min) {
         $errorMsg = sprintf('The value %s is too small for path "%s". Should be greater than or equal to %s', $value, $this->getPath(), $this->min);
     }
     if (isset($this->max) && $value > $this->max) {
         $errorMsg = sprintf('The value %s is too big for path "%s". Should be less than or equal to %s', $value, $this->getPath(), $this->max);
     }
     if (isset($errorMsg)) {
         $ex = new InvalidConfigurationException($errorMsg);
         $ex->setPath($this->getPath());
         throw $ex;
     }
     return $value;
 }