From e48f6841923934063a767e36b293b9c3a3a0a5ca Mon Sep 17 00:00:00 2001 From: Thomas Leeds Date: Sun, 12 May 2024 15:41:01 +0100 Subject: [PATCH] fix: empty tag --- validation_tags_to_schema.go | 2 ++ validation_tags_to_schema_test.go | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/validation_tags_to_schema.go b/validation_tags_to_schema.go index 778f140..ab43328 100644 --- a/validation_tags_to_schema.go +++ b/validation_tags_to_schema.go @@ -192,6 +192,8 @@ func ValidationTagsToSchema(validationTag string) (tagSchema Schema, required bo schema.Pattern = "^urn:[a-zA-Z0-9][a-zA-Z0-9-]{0,31}:([a-zA-Z0-9()+,\\-.:=@;$_!*'%/?#]|%[0-9a-fA-F]{2})+$" // Primitives + case "": + continue case "required": fieldRequired = true diff --git a/validation_tags_to_schema_test.go b/validation_tags_to_schema_test.go index 21d5cbc..df1126c 100644 --- a/validation_tags_to_schema_test.go +++ b/validation_tags_to_schema_test.go @@ -658,6 +658,11 @@ func TestValidateTagsToSchema(t *testing.T) { validateTag: "urn_rfc2141", expectedSchema: singleSchemaFromPattern("^urn:[a-zA-Z0-9][a-zA-Z0-9-]{0,31}:([a-zA-Z0-9()+,\\-.:=@;$_!*'%/?#]|%[0-9a-fA-F]{2})+$"), }, + { + name: "empty", + validateTag: "", + expectedSchema: Schema{}, + }, { name: "required", validateTag: "required",