Skip to content

Commit

Permalink
fix: type assertion
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Theuermann <[email protected]>
  • Loading branch information
mati007thm committed Dec 4, 2024
1 parent e47ffa3 commit 2e4b52d
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions internal/provider/integration_email_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,18 @@ func (d defaultRecipientValidator) ValidateList(ctx context.Context, req validat
}

// Check if the value is true
isDefault, ok := isDefaultAttr.(types.Bool)
if !ok {
switch isDefault := isDefaultAttr.(type) {
case types.Bool:
if isDefault.ValueBool() {
defaultCount++
}
default:
resp.Diagnostics.AddError(
"Invalid Attribute Type",
"The 'is_default' attribute must be a boolean.",
)
return
}

if isDefault.ValueBool() {
defaultCount++
}
}

// Validate that only one recipient is marked as default
Expand All @@ -116,7 +116,6 @@ func (d defaultRecipientValidator) MarkdownDescription(ctx context.Context) stri
return "Ensures that only one recipient is marked as `default`."
}

// NewDefaultRecipientValidator creates a new instance of the validator
func NewDefaultRecipientValidator() validator.List {
return defaultRecipientValidator{}
}
Expand Down

0 comments on commit 2e4b52d

Please sign in to comment.