Skip to content

Commit 636cf0f

Browse files
committed
call NewValidator for each subindex
makes usage consistent with other places, also makes moving to a new index for validation explicit
1 parent 603a535 commit 636cf0f

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

pkg/validation/validate/slice_validator.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,8 @@ func (s *schemaSliceValidator) Validate(data interface{}) *Result {
5454
size := val.Len()
5555

5656
if s.Items != nil && s.Items.Schema != nil {
57-
validator := s.Options.NewValidatorForIndex(0, s.Items.Schema, s.Root, s.Path, s.KnownFormats, s.Options.Options()...)
5857
for i := 0; i < size; i++ {
59-
validator.SetPath(fmt.Sprintf("%s[%d]", s.Path, i))
58+
validator := s.Options.NewValidatorForIndex(i, s.Items.Schema, s.Root, fmt.Sprintf("%s[%d]", s.Path, i), s.KnownFormats, s.Options.Options()...)
6059
value := val.Index(i)
6160
result.Merge(validator.Validate(value.Interface()))
6261
}

0 commit comments

Comments
 (0)