You are here

private function GranularityStringConstraintValidator::isGranularityString in Duration Field 8.2

Same name and namespace in other branches
  1. 3.0.x src/Plugin/Validation/Constraint/GranularityStringConstraintValidator.php \Drupal\duration_field\Plugin\Validation\Constraint\GranularityStringConstraintValidator::isGranularityString()

Check if a string is a valid granularity string.

Parameters

mixed $value: The item to check as a granularity string.

Return value

bool TRUE if the given value is a valid granularity string. FALSE if it is not.

1 call to GranularityStringConstraintValidator::isGranularityString()
GranularityStringConstraintValidator::validate in src/Plugin/Validation/Constraint/GranularityStringConstraintValidator.php
Checks if the passed value is valid.

File

src/Plugin/Validation/Constraint/GranularityStringConstraintValidator.php, line 44

Class

GranularityStringConstraintValidator
Validates the granularity_string constraint.

Namespace

Drupal\duration_field\Plugin\Validation\Constraint

Code

private function isGranularityString($value) {
  if (is_string($value)) {
    return preg_match(GraularityStringInterface::GRANULARITY_STRING_PATTERN, $value);
  }
  return FALSE;
}