You are here

class DateTimeFormatConstraint in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/datetime/src/Plugin/Validation/Constraint/DateTimeFormatConstraint.php \Drupal\datetime\Plugin\Validation\Constraint\DateTimeFormatConstraint
  2. 9 core/modules/datetime/src/Plugin/Validation/Constraint/DateTimeFormatConstraint.php \Drupal\datetime\Plugin\Validation\Constraint\DateTimeFormatConstraint

Validation constraint for DateTime items to ensure the format is correct.

Plugin annotation


@Constraint(
  id = "DateTimeFormat",
  label = @Translation("Datetime format valid for datetime type.", context = "Validation"),
)

Hierarchy

  • class \Drupal\datetime\Plugin\Validation\Constraint\DateTimeFormatConstraint extends \Symfony\Component\Validator\Constraint

Expanded class hierarchy of DateTimeFormatConstraint

File

core/modules/datetime/src/Plugin/Validation/Constraint/DateTimeFormatConstraint.php, line 15

Namespace

Drupal\datetime\Plugin\Validation\Constraint
View source
class DateTimeFormatConstraint extends Constraint {

  /**
   * Message for when the value isn't a string.
   *
   * @var string
   */
  public $badType = "The datetime value must be a string.";

  /**
   * Message for when the value isn't in the proper format.
   *
   * @var string
   */
  public $badFormat = "The datetime value '@value' is invalid for the format '@format'";

  /**
   * Message for when the value did not parse properly.
   *
   * @var string
   */
  public $badValue = "The datetime value '@value' did not parse properly for the format '@format'";

}

Members

Namesort descending Modifiers Type Description Overrides
DateTimeFormatConstraint::$badFormat public property Message for when the value isn't in the proper format.
DateTimeFormatConstraint::$badType public property Message for when the value isn't a string.
DateTimeFormatConstraint::$badValue public property Message for when the value did not parse properly.