You are here

class CountConstraint in Drupal 8

Same name and namespace in other branches
  1. 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

Namesort descending Modifiers Type Description Overrides
CountConstraint::$exactMessage public property
CountConstraint::$maxMessage public property
CountConstraint::$minMessage public property
CountConstraint::validatedBy public function Returns the name of the class that validates this constraint.