minLength : Integer

minLength

Integer

A string instance is valid against this keyword if its length is greater than, or equal to, the value of this keyword.

Value This keyword must be set to a zero or positive integer
Kind Assertion
Applies To String
Base Dialect 2020-12
Changed In None
Introduced In Draft 1
Vocabulary Validation
Specification https://json-schema.org/draft/2020-12/json-schema-validation.html#section-6.3.2
Metaschema https://json-schema.org/draft/2020-12/meta/validation
Official Tests draft2020-12/minLength.json
Default 0
Annotation None
Affected By None
Affects None
Also See

The minLength keyword restricts string instances to consists of an inclusive minimum number of Unicode code-points (logical characters), which is not necessarily the same as the number of bytes in the string.

Remember that JSON Schema is a constraint-driven language. Therefore, non-string instances successfully validate against this keyword. If needed, make use of the type keyword to constraint the accepted type accordingly.

Examples

A schema that constrains string instances to contain at least 3 code points Schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "minLength": 3
}
Valid A string value that consists of 3 code-points is valid Instance
"foo"
Valid A string value that consists of more than 3 code-points is valid Instance
"こんにちは"
Invalid A string value that consists of less than 3 code-points is invalid Instance
"hi"
Valid A non-string value is valid Instance
55