github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/builtin/providers/pagerduty/util.go (about) 1 package pagerduty 2 3 import ( 4 "fmt" 5 6 "github.com/hashicorp/terraform/helper/schema" 7 ) 8 9 // Validate a value against a set of possible values 10 func validateValueFunc(values []string) schema.SchemaValidateFunc { 11 return func(v interface{}, k string) (we []string, errors []error) { 12 value := v.(string) 13 valid := false 14 for _, val := range values { 15 if value == val { 16 valid = true 17 break 18 } 19 } 20 21 if !valid { 22 errors = append(errors, fmt.Errorf("%#v is an invalid value for argument %s. Must be one of %#v", value, k, values)) 23 } 24 return 25 } 26 }