Skip to content

Commit

Permalink
fix: field possible unknown for RequireIfAttributeIsOneOf
Browse files Browse the repository at this point in the history
  • Loading branch information
azrod authored and dmicheneau committed Jun 13, 2023
1 parent 0e449bd commit 6a4935f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/require_if_attribute_is_one_of.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ func (av RequireIfAttributeIsOneOf) Description(_ context.Context) string {
var expectedValueDescritpion string
for i, expectedValue := range av.ExceptedValues {
if i == len(av.ExceptedValues)-1 {
expectedValueDescritpion += fmt.Sprintf("%s, ", expectedValue.String())
expectedValueDescritpion += expectedValue.String()
break
}
expectedValueDescritpion += expectedValue.String()
expectedValueDescritpion += fmt.Sprintf("%s, ", expectedValue.String())
}
return fmt.Sprintf("If %s attribute is set and the value is one of %s, this attribute is REQUIRED", av.PathExpression, expectedValueDescritpion)
}
Expand Down Expand Up @@ -110,7 +110,7 @@ func (av RequireIfAttributeIsOneOf) Validate(ctx context.Context, req RequireIfA

for _, expectedValue := range av.ExceptedValues {
if mpVal.Equal(expectedValue) {
if req.ConfigValue.IsNull() || req.ConfigValue.IsUnknown() {
if req.ConfigValue.IsNull() {
res.Diagnostics.AddAttributeError(
path,
fmt.Sprintf("Invalid configuration for attribute %s", req.Path),
Expand Down

0 comments on commit 6a4935f

Please sign in to comment.