Skip to content

Commit

Permalink
Update minLength.markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
AgniveshChaubey authored Feb 12, 2024
1 parent 67faecc commit 8676c87
Showing 1 changed file with 0 additions and 46 deletions.
46 changes: 0 additions & 46 deletions content/2020-12/validation/minLength.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -16,49 +16,3 @@ related:
- vocabulary: format-annotation
keyword: format
---

The `minLength` keyword is used to specify the minimum length of a string. 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 `Schema requiring minimum string length of 5`>}}
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "string",
"minLength": 5
}
{{</schema>}}

{{<instance-pass `An instance with a string length greater than or equal to 5 is valid`>}}
"This is a valid string"
{{</instance-pass>}}

{{<instance-fail `An instance with a string length less than 5 is invalid`>}}
"foo"
{{</instance-fail>}}

{{<schema `Schema which allows either a string with at least 3 characters or a numeric value`>}}
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": ["string", "number"],
"minLength": 3
}

{{</schema>}}

{{<instance-pass `An instance with a string length greater than or equal to 3 is valid`>}}
"foo"
{{</instance-pass>}}

{{<instance-fail `An instance with a string length less than 3 is valid`>}}
"hi"
{{</instance-fail>}}

{{<instance-pass `An instance with a numeric value is valid`>}}
55
{{</instance-pass>}}

0 comments on commit 8676c87

Please sign in to comment.