You are here

protected function DateBase::validateGnuDateInputFormat in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Plugin/WebformElement/DateBase.php \Drupal\webform\Plugin\WebformElement\DateBase::validateGnuDateInputFormat()

Validate GNU date input format.

Parameters

array $properties: An array of element properties.

string $key: The property name containing the GNU date input format.

Return value

bool TRUE if property's value is a valid GNU date input format or contains a token.

1 call to DateBase::validateGnuDateInputFormat()
DateBase::validateConfigurationForm in src/Plugin/WebformElement/DateBase.php
Form validation handler.

File

src/Plugin/WebformElement/DateBase.php, line 441

Class

DateBase
Provides a base 'date' class.

Namespace

Drupal\webform\Plugin\WebformElement

Code

protected function validateGnuDateInputFormat(array $properties, $key) {
  if (empty($properties[$key])) {
    return TRUE;
  }
  $values = (array) $properties[$key];
  foreach ($values as $value) {
    if (!preg_match('/^\\[[^]]+\\]$/', $value)) {
      if (strtotime($value) === FALSE) {
        return FALSE;
      }
    }
  }
  return TRUE;
}