You are here

public static function OpignoDateRangeWidget::validateDate in Opigno calendar 8

Same name and namespace in other branches
  1. 3.x src/Plugin/Field/FieldWidget/OpignoDateRangeWidget.php \Drupal\opigno_calendar\Plugin\Field\FieldWidget\OpignoDateRangeWidget::validateDate()

Validate the color text field.

File

src/Plugin/Field/FieldWidget/OpignoDateRangeWidget.php, line 329

Class

OpignoDateRangeWidget
Plugin implementation of the 'opigno_daterange' widget.

Namespace

Drupal\opigno_calendar\Plugin\Field\FieldWidget

Code

public static function validateDate($element, FormStateInterface $form_state) {
  $value = $element['#value'];
  if (!preg_match('/^\\d{2}\\/\\d{2}\\/\\d{4}$/i', $value)) {
    $form_state
      ->setError($element, t('The date should be in the mm/dd/yyyy format.'));
  }
}