From 3dbc5b0c2b1e6c11a486fc732580cd9db8d2eec0 Mon Sep 17 00:00:00 2001 From: YuyaKoda <29038315+ponkio-o@users.noreply.github.com> Date: Mon, 27 Mar 2023 12:27:15 +0900 Subject: [PATCH] change: added ValidateFunc for `sigsci_corp_integration` (#149) * fix: added ValidateFunc for corp_integration * fix: typo * Update provider/resource_corp_integration.go Co-authored-by: Shawn Smith * fix: added backquote --------- Co-authored-by: Shawn Smith --- provider/resource_corp_integration.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/provider/resource_corp_integration.go b/provider/resource_corp_integration.go index add45d0..d252063 100644 --- a/provider/resource_corp_integration.go +++ b/provider/resource_corp_integration.go @@ -1,6 +1,7 @@ package provider import ( + "fmt" "log" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" @@ -22,6 +23,12 @@ func resourceCorpIntegration() *schema.Resource { Description: "One of (mailingList, slack, microsoftTeams)", Required: true, ForceNew: true, + ValidateFunc: func(val interface{}, key string) (warns []string, errs []error) { + if !existsInString(val.(string), "mailingList", "slack", "microsoftTeams") { + return nil, []error{fmt.Errorf(`"received type %q is invalid. should be "mailingList", "slack", or "microsoftTeams"`, val.(string))} + } + return nil, nil + }, }, "url": { Type: schema.TypeString,