@@ -289,7 +289,6 @@ func TestArrayDiveValidation(t *testing.T) {
289289 }
290290
291291 errs = validate .Struct (tm )
292-
293292 NotEqual (t , errs , nil )
294293 Equal (t , len (errs .Errors ), 1 )
295294
@@ -311,6 +310,86 @@ func TestArrayDiveValidation(t *testing.T) {
311310 Equal (t , innerSliceError1 .Tag , required )
312311 Equal (t , innerSliceError1 .IsSliceOrArray , false )
313312 Equal (t , len (innerSliceError1 .SliceOrArrayErrs ), 0 )
313+
314+ type Inner struct {
315+ Name string `validate:"required"`
316+ }
317+
318+ type TestMultiDimensionalStructs struct {
319+ Errs [][]Inner `validate:"gt=0,dive,dive"`
320+ }
321+
322+ var errStructArray [][]Inner
323+
324+ errStructArray = append (errStructArray , []Inner {Inner {"ok" }, Inner {"" }, Inner {"" }})
325+ errStructArray = append (errStructArray , []Inner {Inner {"ok" }, Inner {"" }, Inner {"" }})
326+
327+ tms := & TestMultiDimensionalStructs {
328+ Errs : errStructArray ,
329+ }
330+
331+ errs = validate .Struct (tms )
332+ NotEqual (t , errs , nil )
333+ Equal (t , len (errs .Errors ), 1 )
334+
335+ fieldErr , ok = errs .Errors ["Errs" ]
336+ Equal (t , ok , true )
337+ Equal (t , fieldErr .IsPlaceholderErr , true )
338+ Equal (t , fieldErr .IsSliceOrArray , true )
339+ Equal (t , len (fieldErr .SliceOrArrayErrs ), 2 )
340+
341+ sliceError1 , ok = fieldErr .SliceOrArrayErrs [0 ].(* FieldError )
342+ Equal (t , ok , true )
343+ Equal (t , sliceError1 .IsPlaceholderErr , true )
344+ Equal (t , sliceError1 .IsSliceOrArray , true )
345+ Equal (t , len (sliceError1 .SliceOrArrayErrs ), 2 )
346+
347+ innerSliceStructError1 , ok := sliceError1 .SliceOrArrayErrs [1 ].(* StructErrors )
348+ Equal (t , ok , true )
349+ Equal (t , len (innerSliceStructError1 .Errors ), 1 )
350+
351+ innerInnersliceError1 := innerSliceStructError1 .Errors ["Name" ]
352+ Equal (t , innerInnersliceError1 .IsPlaceholderErr , false )
353+ Equal (t , innerInnersliceError1 .IsSliceOrArray , false )
354+ Equal (t , len (innerInnersliceError1 .SliceOrArrayErrs ), 0 )
355+
356+ type TestMultiDimensionalStructsPtr struct {
357+ Errs [][]* Inner `validate:"gt=0,dive,dive"`
358+ }
359+
360+ var errStructPtrArray [][]* Inner
361+
362+ errStructPtrArray = append (errStructPtrArray , []* Inner {& Inner {"ok" }, & Inner {"" }, & Inner {"" }})
363+ errStructPtrArray = append (errStructPtrArray , []* Inner {& Inner {"ok" }, & Inner {"" }, & Inner {"" }})
364+
365+ tmsp := & TestMultiDimensionalStructsPtr {
366+ Errs : errStructPtrArray ,
367+ }
368+
369+ errs = validate .Struct (tmsp )
370+ NotEqual (t , errs , nil )
371+ Equal (t , len (errs .Errors ), 1 )
372+
373+ fieldErr , ok = errs .Errors ["Errs" ]
374+ Equal (t , ok , true )
375+ Equal (t , fieldErr .IsPlaceholderErr , true )
376+ Equal (t , fieldErr .IsSliceOrArray , true )
377+ Equal (t , len (fieldErr .SliceOrArrayErrs ), 2 )
378+
379+ sliceError1 , ok = fieldErr .SliceOrArrayErrs [0 ].(* FieldError )
380+ Equal (t , ok , true )
381+ Equal (t , sliceError1 .IsPlaceholderErr , true )
382+ Equal (t , sliceError1 .IsSliceOrArray , true )
383+ Equal (t , len (sliceError1 .SliceOrArrayErrs ), 2 )
384+
385+ innerSliceStructError1 , ok = sliceError1 .SliceOrArrayErrs [1 ].(* StructErrors )
386+ Equal (t , ok , true )
387+ Equal (t , len (innerSliceStructError1 .Errors ), 1 )
388+
389+ innerInnersliceError1 = innerSliceStructError1 .Errors ["Name" ]
390+ Equal (t , innerInnersliceError1 .IsPlaceholderErr , false )
391+ Equal (t , innerInnersliceError1 .IsSliceOrArray , false )
392+ Equal (t , len (innerInnersliceError1 .SliceOrArrayErrs ), 0 )
314393}
315394
316395func TestNilStructPointerValidation (t * testing.T ) {
0 commit comments