mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Signed-off-by: Janos Bonic <86970079+janosdebugs@users.noreply.github.com>
This commit is contained in:
parent
70dd385136
commit
5154b14818
@ -128,7 +128,7 @@ func (a *Attribute) internalValidate(name, prefix string) error {
|
||||
|
||||
if a.Type != cty.NilType {
|
||||
if a.NestedType != nil {
|
||||
err = multierror.Append(fmt.Errorf("%s: Type and NestedType cannot both be set", name))
|
||||
err = multierror.Append(err, fmt.Errorf("%s: Type and NestedType cannot both be set", name))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -134,6 +134,32 @@ func TestBlockInternalValidate(t *testing.T) {
|
||||
},
|
||||
[]string{"foo: either Type or NestedType must be defined"},
|
||||
},
|
||||
"attribute with both type and nestedtype should not suppress other validation messages": {
|
||||
&Block{
|
||||
Attributes: map[string]*Attribute{
|
||||
"foo": {
|
||||
// These properties are here to make sure other errors are also reported.
|
||||
Optional: true,
|
||||
Required: true,
|
||||
// Here's what we actually want to validate:
|
||||
Type: cty.String,
|
||||
NestedType: &Object{
|
||||
Nesting: NestingSingle,
|
||||
Attributes: map[string]*Attribute{
|
||||
"foo": {
|
||||
Type: cty.String,
|
||||
Required: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
[]string{
|
||||
"foo: cannot set both Optional and Required",
|
||||
"foo: Type and NestedType cannot both be set",
|
||||
},
|
||||
},
|
||||
/* FIXME: This caused errors when applied to existing providers (oci)
|
||||
and cannot be enforced without coordination.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user