number = $number; } /** * @inheritDoc */ public function validate(ValidationContext $context, Schema $schema): ?ValidationError { if ($context->currentData() <= $this->number) { return null; } return $this->error($schema, $context, 'maximum', "Number must be lower than or equal to {max}", [ 'max' => $this->number, ]); } }