Skip to content

Commit 02ef96d

Browse files
add example for maxLength keyword demonstrating string length validation with unicode characters
1 parent 25bede3 commit 02ef96d

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

content/2020-12/validation/maxLength.markdown

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,20 @@ The `maxLength` keyword is used to specify the maximum length of a string instan
6161

6262
{{<instance-pass `An instance with a numeric value is valid`>}}
6363
55
64-
{{</instance-pass>}}
64+
{{</instance-pass>}}
65+
66+
{{<schema `Schema for maximum string length validation with unicode characters`>}}
67+
{
68+
"$schema": "https://json-schema.org/draft/2020-12/schema",
69+
"type": "string",
70+
"maxLength": 3
71+
}
72+
{{</schema>}}
73+
74+
{{<instance-pass `An instance with 3 or less characters is valid`>}}
75+
"\u0066\u006F\u006F" // --> "foo"
76+
{{</instance-pass>}}
77+
78+
{{<instance-fail `An instance with more than 3 characters is invalid`>}}
79+
"\u0048\u0065\u006C\u006C\u006F" // --> 'Hello'
80+
{{</instance-fail>}}

0 commit comments

Comments
 (0)