Skip to main content

invalid-min-length

Rejects a numeric minLength below zero on a string schema.

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

Intent

String length cannot be negative. A negative constraint is contradictory and cannot describe valid data.

Flags

String schemas—including multi-type schemas containing string—with numeric minLength < 0. Missing, nonnumeric, and non-string cases are left to structural validation.

See it fail

name:
type: string
minLength: -1

Diagnostic: minLength -1 cannot be less than 0

Fix it

name:
type: string
minLength: 0

Configure

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

Nearby: invalid-max-length, length-exceeds-limit.