AllowedValuesConstraint.php

Same filename in other branches
  1. 9 core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/AllowedValuesConstraint.php
  2. 8.9.x core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/AllowedValuesConstraint.php
  3. 11.x core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/AllowedValuesConstraint.php

Namespace

Drupal\Core\Validation\Plugin\Validation\Constraint

File

core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/AllowedValuesConstraint.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\Choice;

/**
 * Checks for the value being allowed.
 *
 * @see \Drupal\Core\TypedData\OptionsProviderInterface
 */
class AllowedValuesConstraint extends Choice {
    
    /**
     * {@inheritdoc}
     */
    public function __construct(...$args) {
        $this->strict = TRUE;
        $this->minMessage = 'You must select at least %limit choice.|You must select at least %limit choices.';
        $this->maxMessage = 'You must select at most %limit choice.|You must select at most %limit choices.';
        parent::__construct(...$args);
    }

}

Classes

Title Deprecated Summary
AllowedValuesConstraint Checks for the value being allowed.

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