mirror of
https://gitee.com/johng/gf.git
synced 2024-11-30 03:07:45 +08:00
* 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:
parent
c083b333d8
commit
27609d8da8
@ -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
|
||||
|
@ -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")
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user