invalid-max-length
Rejects schemas whose numeric maxLength is smaller than numeric minLength.
| Attribute | Value |
|---|---|
| Category | Schema |
| Maturity | Platinum |
| OpenAPI | Swagger 2.0; OpenAPI 3.0, 3.1, 3.2 |
| Starter | Off |
| Lenient | Warning |
| Recommended–Complete | Error |
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.