Skip to content

Commit

Permalink
Use 'tfsdk.ValueAs' in 'UniqueItems' validator.
Browse files Browse the repository at this point in the history
  • Loading branch information
ewbankkit committed Feb 24, 2022
1 parent fd72534 commit d4411ce
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions internal/validate/unique_items.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@ func (v uniqueItemsValidator) MarkdownDescription(ctx context.Context) string {

// Validate performs the validation.
func (v uniqueItemsValidator) Validate(ctx context.Context, request tfsdk.ValidateAttributeRequest, response *tfsdk.ValidateAttributeResponse) {
list, ok := request.AttributeConfig.(types.List)
var list types.List

if !ok {
response.Diagnostics.Append(diag.NewIncorrectValueTypeAttributeError(
request.AttributePath,
request.AttributeConfig,
))
diags := tfsdk.ValueAs(ctx, request.AttributeConfig, &list)

if diags.HasError() {
response.Diagnostics = append(response.Diagnostics, diags...)

return
}
Expand Down

0 comments on commit d4411ce

Please sign in to comment.