in internal/azure/types/union_type.go [22:58]
func (t *UnionType) Validate(body interface{}, path string) []error {
if t == nil || body == nil {
return []error{}
}
errors := make([]error, 0)
valid := false
for _, element := range t.Elements {
if element.Type == nil {
continue
}
temp := (*element.Type).Validate(body, path)
if len(temp) == 0 {
valid = true
break
}
}
if !valid {
options := make([]string, 0)
for _, element := range t.Elements {
if element.Type != nil {
if stringLiteralType, ok := (*element.Type).(*StringLiteralType); ok {
options = append(options, stringLiteralType.Value)
}
}
}
if len(options) == 0 {
errors = append(errors, utils.ErrorNotMatchAny(path))
} else {
value := ""
if current, ok := body.(string); ok {
value = current
}
errors = append(errors, utils.ErrorNotMatchAnyValues(path, value, options))
}
}
return errors
}