4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Config\Definition;
14 use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
17 * This node represents a numeric value in the config tree.
19 * @author David Jeanmonod <david.jeanmonod@gmail.com>
21 class NumericNode extends ScalarNode
26 public function __construct($name, NodeInterface $parent = null, $min = null, $max = null)
28 parent::__construct($name, $parent);
36 protected function finalizeValue($value)
38 $value = parent::finalizeValue($value);
41 if (isset($this->min) && $value < $this->min) {
42 $errorMsg = sprintf('The value %s is too small for path "%s". Should be greater than or equal to %s', $value, $this->getPath(), $this->min);
44 if (isset($this->max) && $value > $this->max) {
45 $errorMsg = sprintf('The value %s is too big for path "%s". Should be less than or equal to %s', $value, $this->getPath(), $this->max);
47 if (isset($errorMsg)) {
48 $ex = new InvalidConfigurationException($errorMsg);
49 $ex->setPath($this->getPath());
59 protected function isValueEmpty($value)
61 // a numeric value cannot be empty