1
0
mirror of https://github.com/mgechev/revive.git synced 2025-11-23 22:04:49 +02:00

feature: add suport of validate struct tags in struct-tag rule (#1244)

This commit is contained in:
chavacava
2025-02-20 19:48:35 +01:00
committed by GitHub
parent 4f342352f0
commit 3bbfedbf43
4 changed files with 236 additions and 0 deletions

View File

@@ -146,3 +146,15 @@ type MapStruct struct {
Field1 string `mapstructure:",squash,reminder,omitempty"`
OtherField string `mapstructure:",unknownOption"` // MATCH /unknown option 'unknownOption' in Mapstructure tag/
}
type ValidateUser struct {
Username string `validate:"required,min=3,max=32"`
Email string `validate:"required,email"`
Password string `validate:"required,min=8,max=32"`
Biography string `validate:"min=0,max=1000"`
DisplayName string `validate:"displayName,min=3,max=32"` // MATCH /unknown option 'displayName' in validate tag/
Complex string `validate:"gt=0,dive,keys,eq=1|eq=2,endkeys,required"`
BadComplex string `validate:"gt=0,keys,eq=1|eq=2,endkeys,required"` // MATCH /option 'keys' must follow a 'dive' option in validate tag/
BadComplex2 string `validate:"gt=0,dive,eq=1|eq=2,endkeys,required"` // MATCH /option 'endkeys' without a previous 'keys' option in validate tag/
BadComplex3 string `validate:"gt=0,dive,keys,eq=1|eq=2,endkeys,endkeys,required"` // MATCH /option 'endkeys' without a previous 'keys' option in validate tag/
}