class CountConstraint

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/CountConstraint.php \Drupal\Core\Validation\Plugin\Validation\Constraint\CountConstraint
  2. 10 core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/CountConstraint.php \Drupal\Core\Validation\Plugin\Validation\Constraint\CountConstraint
  3. 11.x 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

Title Sort descending Modifiers Object type Summary
CountConstraint::$exactMessage public property
CountConstraint::$maxMessage public property
CountConstraint::$minMessage public property
CountConstraint::validatedBy public function

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