From 87db8b3b4312815d93a871c79a092b0fc54993fa Mon Sep 17 00:00:00 2001 From: ebilhoo Date: Tue, 25 Apr 2017 20:06:33 +0000 Subject: [PATCH] use validation helper --- .../ultradns/resource_ultradns_rdpool.go | 29 ++++++------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/builtin/providers/ultradns/resource_ultradns_rdpool.go b/builtin/providers/ultradns/resource_ultradns_rdpool.go index f18870a6c..5f8bbff6c 100644 --- a/builtin/providers/ultradns/resource_ultradns_rdpool.go +++ b/builtin/providers/ultradns/resource_ultradns_rdpool.go @@ -7,6 +7,7 @@ import ( "github.com/Ensighten/udnssdk" "github.com/hashicorp/terraform/helper/schema" + "github.com/hashicorp/terraform/helper/validation" ) func resourceUltradnsRdpool() *schema.Resource { @@ -39,28 +40,16 @@ func resourceUltradnsRdpool() *schema.Resource { Type: schema.TypeString, Optional: true, Default: "ROUND_ROBIN", - ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) { - value := v.(string) - if value != "ROUND_ROBIN" && value != "FIXED" && value != "RANDOM" { - errors = append(errors, fmt.Errorf( - "Only 'ROUND_ROBIN', 'FIXED', and 'RANDOM' are supported values for 'order'")) - } - return - }, + ValidateFunc: validation.StringInSlice([]string{ + "ROUND_ROBIN", + "FIXED", + "RANDOM", + }, false), }, "description": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) { - if v != nil { - value := v.(string) - if len(value) > 255 { - errors = append(errors, fmt.Errorf( - "'description' length must be 0-255")) - } - } - return - }, + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringLenBetween(0, 255), }, "ttl": &schema.Schema{ Type: schema.TypeInt,