protected function DateBase::validateGnuDateInputFormat in Webform 8.5
Same name and namespace in other branches
- 6.x 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 409
Class
- DateBase
- Provides a base 'date' class.
Namespace
Drupal\webform\Plugin\WebformElementCode
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;
}