From 469a4b614c8dc857c4549997a92ed8039a71af47 Mon Sep 17 00:00:00 2001 From: Agnivesh Chaubey Date: Tue, 20 Feb 2024 12:23:16 +0530 Subject: [PATCH] add description and examples for `minLength` keyword (#109) This PR addressed #89 --- content/2020-12/validation/minLength.markdown | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/content/2020-12/validation/minLength.markdown b/content/2020-12/validation/minLength.markdown index 55fd4540..9f226794 100644 --- a/content/2020-12/validation/minLength.markdown +++ b/content/2020-12/validation/minLength.markdown @@ -16,3 +16,49 @@ related: - vocabulary: format-annotation keyword: format --- + +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 +{{}} \ No newline at end of file