func()

in mmv1/api/type.go [353:387]


func (t *Type) Validate(rName string) {
	if t.Name == "" {
		log.Fatalf("Missing `name` for proprty with type %s in resource %s", t.Type, rName)
	}

	if t.Output && t.Required {
		log.Fatalf("Property %s cannot be output and required at the same time in resource %s.", t.Name, rName)
	}

	if t.DefaultFromApi && t.DefaultValue != nil {
		log.Fatalf("'default_value' and 'default_from_api' cannot be both set in resource %s", rName)
	}

	if t.WriteOnly && (t.DefaultFromApi || t.Output) {
		log.Fatalf("Property %s cannot be write_only and default_from_api or output at the same time in resource %s", t.Name, rName)
	}

	if t.WriteOnly && t.Sensitive {
		log.Fatalf("Property %s cannot be write_only and sensitive at the same time in resource %s", t.Name, rName)
	}

	t.validateLabelsField()

	switch {
	case t.IsA("Array"):
		t.ItemType.Validate(rName)
	case t.IsA("Map"):
		t.ValueType.Validate(rName)
	case t.IsA("NestedObject"):
		for _, p := range t.Properties {
			p.Validate(rName)
		}
	default:
	}
}