Constraint.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace Drupal\Core\Validation\Annotation;
  3. use Drupal\Component\Annotation\Plugin;
  4. /**
  5. * Defines a validation constraint annotation object.
  6. *
  7. * Plugin Namespace: Plugin\Validation\Constraint
  8. *
  9. * For a working example, see
  10. * \Drupal\Core\Validation\Plugin\Validation\Constraint\LengthConstraint
  11. *
  12. * @see \Drupal\Core\Validation\ConstraintManager
  13. * @see \Symfony\Component\Validator\Constraint
  14. * @see hook_validation_constraint_alter()
  15. * @see plugin_api
  16. *
  17. * @Annotation
  18. */
  19. class Constraint extends Plugin {
  20. /**
  21. * The constraint plugin ID.
  22. *
  23. * @var string
  24. */
  25. public $id;
  26. /**
  27. * The human-readable name of the constraint plugin.
  28. *
  29. * @ingroup plugin_translatable
  30. *
  31. * @var string|\Drupal\Core\Annotation\Translation
  32. */
  33. public $label;
  34. /**
  35. * An array of DataType plugin IDs for which this constraint applies. Valid
  36. * values are any types registered by the typed data API, or an array of
  37. * multiple type names. For supporting all types, FALSE may be specified. The
  38. * key defaults to an empty array, which indicates no types are supported.
  39. *
  40. * @var string|string[]|false
  41. *
  42. * @see \Drupal\Core\TypedData\Annotation\DataType
  43. */
  44. public $type = [];
  45. }