class TweetEmbedCodeConstraintValidator in Media entity Twitter 8
Validates the TweetEmbedCode constraint.
Hierarchy
- class \Drupal\media_entity_twitter\Plugin\Validation\Constraint\TweetEmbedCodeConstraintValidator extends \Symfony\Component\Validator\ConstraintValidator uses EmbedCodeValueTrait
Expanded class hierarchy of TweetEmbedCodeConstraintValidator
1 file declares its use of TweetEmbedCodeConstraintValidator
- ConstraintsTest.php in tests/src/ Unit/ ConstraintsTest.php 
File
- src/Plugin/ Validation/ Constraint/ TweetEmbedCodeConstraintValidator.php, line 13 
Namespace
Drupal\media_entity_twitter\Plugin\Validation\ConstraintView source
class TweetEmbedCodeConstraintValidator extends ConstraintValidator {
  use EmbedCodeValueTrait;
  /**
   * {@inheritdoc}
   */
  public function validate($value, Constraint $constraint) {
    $value = $this
      ->getEmbedCode($value);
    if (!isset($value)) {
      return;
    }
    foreach (Twitter::$validationRegexp as $pattern => $key) {
      if (preg_match($pattern, $value)) {
        return;
      }
    }
    $this->context
      ->addViolation($constraint->message);
  }
}Members
| Name   | Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| EmbedCodeValueTrait:: | protected | function | Extracts the raw embed code from input which may or may not be wrapped. | |
| TweetEmbedCodeConstraintValidator:: | public | function | Checks if the passed value is valid. | 
