Skip to main content

invalid-max-length

Rejects schemas whose numeric maxLength is smaller than numeric minLength.

AttributeValue
CategorySchema
MaturityPlatinum
OpenAPISwagger 2.0; OpenAPI 3.0, 3.1, 3.2
StarterOff
LenientWarning
Recommended–CompleteError

Intent

A maximum below the minimum creates an empty valid range: no string can satisfy both constraints.

Flags

A schema containing numeric minLength and maxLength where maxLength < minLength. The rule does not require either constraint and ignores nonnumeric values.

See it fail

name:
type: string
minLength: 10
maxLength: 5

Diagnostic: maxLength 5 cannot be less than minLength 10

Fix it

name:
type: string
minLength: 5
maxLength: 10

Configure

profiles:
default:
rules:
extends: [recommended]
override:
invalid-max-length: warn

Nearby: invalid-min-length, pattern-length-incompatible.