Skip to content

Commit

Permalink
chore: add unique validation (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
TommoLeedsy authored Jan 26, 2024
1 parent 940457e commit 1c07902
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions validation_tags_to_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ func ValidationTagsToSchema(validationTag string) (tagSchema Schema, required bo
for i, str := range strs {
schema.Enum[i] = str
}
case "unique":
schema.UniqueItems = true

// Aliases
case "iscolor":
Expand Down
7 changes: 7 additions & 0 deletions validation_tags_to_schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,13 @@ func TestValidateTagsToSchema(t *testing.T) {
Enum: []interface{}{"foo", "bar"},
}),
},
{
name: "unique",
validateTag: "unique",
expectedSchema: allOfSchemas(Schema{
UniqueItems: true,
}),
},
{
name: "iscolor",
validateTag: "iscolor",
Expand Down

0 comments on commit 1c07902

Please sign in to comment.