Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x

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\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(...$args) {
        $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(...$args);
    }

}

Classes

Title Deprecated Summary
RangeConstraint Range constraint.

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal