in internal/azure/types/union_type.go [32:68]
func (t *UnionType) Validate(body attr.Value, path string) []error {
if t == nil || body == nil || body.IsNull() || body.IsUnknown() {
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.(types.String); ok {
value = current.ValueString()
}
errors = append(errors, utils.ErrorNotMatchAnyValues(path, value, options))
}
}
return errors
}