RangeConstraint.php

Same filename and directory in other branches
  1. 11.x core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/RangeConstraint.php
  2. 10 core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/RangeConstraint.php
  3. 9 core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/RangeConstraint.php
  4. 8.9.x core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/RangeConstraint.php

Namespace

Drupal\Core\Validation\Plugin\Validation\Constraint

File

core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/RangeConstraint.php

View source
<?php

namespace Drupal\Core\Validation\Plugin\Validation\Constraint;

use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\Validation\Attribute\Constraint;
use Symfony\Component\Validator\Attribute\HasNamedArguments;
use Symfony\Component\Validator\Constraints\Range;

/**
 * Range constraint.
 *
 * Overrides the symfony constraint to use Drupal-style replacement patterns.
 *
 * @todo Move this below the TypedData core component.
 */
class RangeConstraint extends Range {
  
  /**
   * {@inheritdoc}
   */
  public function __construct(?array $options = NULL, ?string $notInRangeMessage = NULL, ?string $minMessage = NULL, ?string $maxMessage = NULL, ?string $invalidMessage = NULL, ?string $invalidDateTimeMessage = NULL, mixed $min = NULL, ?string $minPropertyPath = NULL, mixed $max = NULL, ?string $maxPropertyPath = NULL, ?array $groups = NULL, mixed $payload = NULL) {
    $this->notInRangeMessage = 'This value should be between %min and %max.';
    $this->minMessage = 'This value should be %limit or more.';
    $this->maxMessage = 'This value should be %limit or less.';
    parent::__construct($options, $notInRangeMessage, $minMessage, $maxMessage, $invalidMessage, $invalidDateTimeMessage, $min, $minPropertyPath, $max, $maxPropertyPath, $groups, $payload);
  }

}

Classes

Title Deprecated Summary
RangeConstraint Range constraint.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.