From 2e4b52d6fcab959b4d3038e55fd67eca5c115550 Mon Sep 17 00:00:00 2001 From: Matthias Theuermann Date: Wed, 4 Dec 2024 10:54:43 +0100 Subject: [PATCH] fix: type assertion Signed-off-by: Matthias Theuermann --- internal/provider/integration_email_resource.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/internal/provider/integration_email_resource.go b/internal/provider/integration_email_resource.go index 456f700..46bb57a 100644 --- a/internal/provider/integration_email_resource.go +++ b/internal/provider/integration_email_resource.go @@ -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 @@ -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{} }