You are here

class CountConstraint in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/CountConstraint.php \Drupal\Core\Validation\Plugin\Validation\Constraint\CountConstraint
  2. 9 core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/CountConstraint.php \Drupal\Core\Validation\Plugin\Validation\Constraint\CountConstraint

Count constraint.

Overrides the symfony constraint to use Drupal-style replacement patterns.

Plugin annotation


@Constraint(
  id = "Count",
  label = @Translation("Count", context = "Validation"),
  type = { "list" }
)

Hierarchy

  • class \Drupal\Core\Validation\Plugin\Validation\Constraint\CountConstraint extends \Symfony\Component\Validator\Constraints\Count

Expanded class hierarchy of CountConstraint

File

core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/CountConstraint.php, line 18

Namespace

Drupal\Core\Validation\Plugin\Validation\Constraint
View source
class CountConstraint extends Count {
  public $minMessage = 'This collection should contain %limit element or more.|This collection should contain %limit elements or more.';
  public $maxMessage = 'This collection should contain %limit element or less.|This collection should contain %limit elements or less.';
  public $exactMessage = 'This collection should contain exactly %limit element.|This collection should contain exactly %limit elements.';

  /**
   * {@inheritdoc}
   */
  public function validatedBy() {
    return '\\Symfony\\Component\\Validator\\Constraints\\CountValidator';
  }

}

Members