in internal/azure/types/array_type.go [41:72]
func (t *ArrayType) Validate(body interface{}, path string) []error {
if t == nil || body == nil {
return []error{}
}
errors := make([]error, 0)
var itemType *TypeBase
if t.ItemType != nil {
itemType = t.ItemType.Type
}
// check body type
bodyArray, ok := body.([]interface{})
if !ok {
errors = append(errors, utils.ErrorMismatch(path, "array", fmt.Sprintf("%T", body)))
return errors
}
// check the length
if t.MinLength != nil && len(bodyArray) < *t.MinLength {
errors = append(errors, utils.ErrorCommon(path, fmt.Sprintf("array length is less than %d", *t.MinLength)))
}
if t.MaxLength != nil && len(bodyArray) > *t.MaxLength {
errors = append(errors, utils.ErrorCommon(path, fmt.Sprintf("array length is greater than %d", *t.MaxLength)))
}
for index, value := range bodyArray {
if itemType != nil {
errors = append(errors, (*itemType).Validate(value, path+"."+strconv.Itoa(index))...)
}
}
return errors
}