@@ -860,6 +860,7 @@ func TestIssues_120(t *testing.T) {
860860}
861861
862862// https://github.com/gookit/validate/issues/124
863+ // Validate array/slice items #124
863864func TestIssue_124 (t * testing.T ) {
864865 m := map [string ]any {
865866 "names" : []string {"John" , "Jane" , "abc" },
@@ -1268,7 +1269,7 @@ func TestIssues_192(t *testing.T) {
12681269 Main1 * struct {
12691270 Child11 int `json:"child11" validate:"required"`
12701271 Child12 int `json:"child12" validate:"required"`
1271- } `json:"main1" validate:"optional"` // optional sometimes
1272+ } `json:"main1" validate:"optional"` // optional - will not validate Main1.* on Main1 is nil
12721273
12731274 Main2 * struct {
12741275 Child21 int `json:"child21" validate:"required"`
@@ -1296,9 +1297,9 @@ func TestIssues_192(t *testing.T) {
12961297 assert .StrContains (t , v .Errors .String (), "main1.child11 is required to not be empty" )
12971298 })
12981299
1299- // set main1 = nil, should not validate Main1.child1
1300+ // set main1 = nil, should not validate Main1.*
13001301 t .Run ("set main1 to nil" , func (t * testing.T ) {
1301- req .Main1 = nil // TODO 应该不验证child1字段了
1302+ req .Main1 = nil // fields under Main1 will not be validated
13021303 v := validate .Struct (req )
13031304 assert .True (t , v .Validate ())
13041305 })
0 commit comments