minLength : Integer
minLength
IntegerA string instance is valid against this keyword if its length is greater than, or equal to, the value of this keyword.
Kind | Assertion |
---|---|
Applies To | String |
Dialect | 2020-12 |
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 |
Also see |
|
The minLength
keyword is used to specify the minimum length of a string instance. It defines the minimum number of characters that a valid string must have to satisfy the schema.
- Applies only to string data types.
- Value must be a non-negative integer.
- String length is counted in characters, not bytes.
- Validation succeeds if the string length is greater than or equal to the specified
minLength
.
Examples
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "string",
"minLength": 5
}
"This is a valid string"
"foo"
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": [ "string", "number" ],
"minLength": 3
}
"foo"
"hi"
55