Skip to content

Commit

Permalink
add example for maxLength keyword demonstrating string length validat…
Browse files Browse the repository at this point in the history
…ion with unicode characters
  • Loading branch information
AgniveshChaubey committed Feb 12, 2024
1 parent 25bede3 commit 02ef96d
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion content/2020-12/validation/maxLength.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,20 @@ The `maxLength` keyword is used to specify the maximum length of a string instan

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

{{<schema `Schema for maximum string length validation with unicode characters`>}}
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "string",
"maxLength": 3
}
{{</schema>}}

{{<instance-pass `An instance with 3 or less characters is valid`>}}
"\u0066\u006F\u006F" // --> "foo"
{{</instance-pass>}}

{{<instance-fail `An instance with more than 3 characters is invalid`>}}
"\u0048\u0065\u006C\u006C\u006F" // --> 'Hello'
{{</instance-fail>}}

0 comments on commit 02ef96d

Please sign in to comment.