You are here

abstract class Iso8601StringConstraintValidatorBase in Duration Field 8.2

Same name and namespace in other branches
  1. 3.0.x src/Plugin/Validation/Constraint/Iso8601StringConstraintValidatorBase.php \Drupal\duration_field\Plugin\Validation\Constraint\Iso8601StringConstraintValidatorBase

Provides a base for validating ISO 8601 String constraints.

Hierarchy

Expanded class hierarchy of Iso8601StringConstraintValidatorBase

File

src/Plugin/Validation/Constraint/Iso8601StringConstraintValidatorBase.php, line 11

Namespace

Drupal\duration_field\Plugin\Validation\Constraint
View source
abstract class Iso8601StringConstraintValidatorBase extends ConstraintValidator {

  /**
   * Test if a string is a valid ISO 8601 duration string.
   *
   * @param mixed $value
   *   The item to check as an ISO 8601 duration string.
   *
   * @return bool
   *   TRUE if the given value is a valid ISO 8601 duration string. FALSE if it
   *   is not.
   */
  protected function isIso8601String($value) {
    if (is_string($value)) {
      return preg_match(Iso8601StringInterface::DURATION_STRING_PATTERN, $value);
    }
    return FALSE;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Iso8601StringConstraintValidatorBase::isIso8601String protected function Test if a string is a valid ISO 8601 duration string.