* CI updates

* fix issue in OpenAPI json marshaling of embedded struct definition; improve command gen service

* improve logging content printing for internal log

* fix issue #1921
This commit is contained in:
John Guo 2022-08-26 14:30:49 +08:00 committed by GitHub
parent c083b333d8
commit 27609d8da8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 1 deletions

View File

@ -560,8 +560,13 @@ func (v *Validator) doCheckValueRecursively(ctx context.Context, in doCheckValue
// Ignore data, assoc, rules and messages from parent.
var (
validator = v.Clone()
toBeValidatedObject = reflect.New(in.Type).Interface()
toBeValidatedObject interface{}
)
if in.Type.Kind() == reflect.Ptr {
toBeValidatedObject = reflect.New(in.Type.Elem()).Interface()
} else {
toBeValidatedObject = reflect.New(in.Type).Interface()
}
validator.assoc = nil
validator.rules = nil
validator.messages = nil

View File

@ -399,3 +399,25 @@ func Test_Issue1983(t *testing.T) {
t.AssertNil(err)
})
}
// https://github.com/gogf/gf/issues/1921
func Test_Issue1921(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
type SearchOption struct {
Size int `v:"max:100"`
}
type SearchReq struct {
Option *SearchOption `json:"option,omitempty"`
}
var (
req = SearchReq{
Option: &SearchOption{
Size: 10000,
},
}
)
err := g.Validator().Data(req).Run(ctx)
t.Assert(err, "The Size value `10000` must be equal or lesser than 100")
})
}