registry = $registry; $this->validator = $validator; } public function initialize(Automation $automation): void { } public function visitNode(Automation $automation, AutomationNode $node): void { $step = $node->getStep(); $registryStep = $this->registry->getStep($step->getKey()); if (!$registryStep) { return; } $schema = $registryStep->getArgsSchema(); $properties = $schema->toArray()['properties'] ?? null; if (!$properties) { $this->validator->validate($schema, $step->getArgs()); return; } $errors = []; foreach ($properties as $property => $propertySchema) { $schemaToValidate = array_merge( $schema->toArray(), ['properties' => [$property => $propertySchema]] ); try { $this->validator->validateSchemaArray( $schemaToValidate, $step->getArgs(), $property ); } catch (ValidationException $e) { $errors[$property] = $e->getWpError()->get_error_code(); } } if ($errors) { $throwable = ValidationException::create(); foreach ($errors as $errorKey => $errorMsg) { $throwable->withError((string)$errorKey, (string)$errorMsg); } throw $throwable; } } public function complete(Automation $automation): void { } }