'INVALID_CIDR_ERROR', self::OUT_OF_RANGE_ERROR => 'OUT_OF_RANGE_VIOLATION']; private const NET_MAXES = [Ip::ALL => 128, Ip::V4 => 32, Ip::V6 => 128]; public $version = Ip::ALL; public $message = 'This value is not a valid CIDR notation.'; public $netmaskRangeViolationMessage = 'The value of the netmask should be between {{ min }} and {{ max }}.'; public $netmaskMin = 0; public $netmaskMax; public function __construct(?array $options = null, ?string $version = null, ?int $netmaskMin = null, ?int $netmaskMax = null, ?string $message = null, ?array $groups = null, $payload = null) { $this->version = $version ?? $options['version'] ?? $this->version; if (!\in_array($this->version, \array_keys(self::NET_MAXES))) { throw new ConstraintDefinitionException(\sprintf('The option "version" must be one of "%s".', \implode('", "', \array_keys(self::NET_MAXES)))); } $this->netmaskMin = $netmaskMin ?? $options['netmaskMin'] ?? $this->netmaskMin; $this->netmaskMax = $netmaskMax ?? $options['netmaskMax'] ?? self::NET_MAXES[$this->version]; $this->message = $message ?? $this->message; unset($options['netmaskMin'], $options['netmaskMax'], $options['version']); if ($this->netmaskMin < 0 || $this->netmaskMax > self::NET_MAXES[$this->version] || $this->netmaskMin > $this->netmaskMax) { throw new ConstraintDefinitionException(\sprintf('The netmask range must be between 0 and %d.', self::NET_MAXES[$this->version])); } parent::__construct($options, $groups, $payload); } }