Skip to content

Commit 8be7fa6

Browse files
authored
fix: rule struct-tag false positive on validate:omitempty (#1525)
1 parent ec8439e commit 8be7fa6

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

rule/struct_tag.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,7 @@ var validateSingleOptions = map[string]struct{}{
843843
"multibyte": {},
844844
"number": {},
845845
"numeric": {},
846+
"omitempty": {},
846847
"port": {},
847848
"postcode_iso3166_alpha2": {},
848849
"postcode_iso3166_alpha2_field": {},

testdata/struct_tag.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ type MapStruct struct {
156156
}
157157

158158
type ValidateUser struct {
159+
Id string `validate:"omitempty,min=3,max=32"`
159160
Username string `validate:"required,min=3,max=32"`
160161
Email string `validate:"required,email"`
161162
Password string `validate:"required,min=8,max=32"`

0 commit comments

Comments
 (0)