Skip to content

Commit

Permalink
fix environment variable branch value validation
Browse files Browse the repository at this point in the history
  • Loading branch information
ramonsnir committed Aug 27, 2024
1 parent 64a9808 commit c71d142
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,20 @@ func (av EnvironmentVariableContextParameterValidator) Validate(ctx context.Cont
continue
}

isBranch := !mpVal.IsNull() && mpVal.Equal(listValue)
var mpValList basetypes.ListValue
mpValList, diags = types.ListValue(types.StringType, []attr.Value{mpVal})
res.Diagnostics.Append(diags...)

// Collect all errors
if diags.HasError() {
continue
}
isBranch := !mpVal.IsNull() && mpValList.Equal(listValue)

if isNonEmpty != isBranch {
res.Diagnostics.Append(validatordiag.InvalidAttributeCombinationDiagnostic(
req.Path,
fmt.Sprintf("Attribute %q must be a non-empty string iff %q is specified", req.Path, mp),
fmt.Sprintf("Attribute %q must be a non-empty string iff %q is specified %q %q %q", req.Path, mp, listValue, mpVal, req.ConfigValue),
))
}
}
Expand Down

0 comments on commit c71d142

Please sign in to comment.