/** * {@inheritdoc} */ public function validate($value, Constraint $constraint) { $regexes = $constraint->getRegularExpressionsOption(); if (empty($value)) { return; } $matches = []; $main_property = $value->mainPropertyName(); $embed_code = $value->get($main_property)->getValue(); foreach ($regexes as $reqular_expr) { if (preg_match($reqular_expr, $embed_code, $item_matches)) { $matches[] = $item_matches; } } if (empty($matches)) { $this->context->addViolation($constraint->message); } }