required = $required; } /** * @inheritDoc */ public function validate(ValidationContext $context, Schema $schema): ?ValidationError { $data = $context->currentData(); $max = $context->maxErrors(); $list = []; foreach ($this->required as $name) { if (!property_exists($data, $name)) { $list[] = $name; if (--$max <= 0) { break; } } } if (!$list) { return null; } return $this->error($schema, $context, 'required', 'The required properties ({missing}) are missing', [ 'missing' => $list, ]); } }