length = $length; } /** * @inheritDoc */ public function validate(ValidationContext $context, Schema $schema): ?ValidationError { $length = $context->getStringLength(); if ($length <= $this->length) { return null; } return $this->error($schema, $context, 'maxLength', "Maximum string length is {max}, found {length}", [ 'max' => $this->length, 'length' => $length, ]); } }