provider/rundeck) enable validation for multiple values in an array (#8913)

This commit is contained in:
BobVanB 2016-12-13 12:40:31 +01:00 committed by Paul Stack
parent 49cdb64426
commit a60a3764f2
1 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,25 @@
package rundeck
import (
"fmt"
"github.com/hashicorp/terraform/helper/schema"
)
func validateValueFunc(values []string) schema.SchemaValidateFunc {
return func(v interface{}, k string) (we []string, errors []error) {
value := v.(string)
valid := false
for _, role := range values {
if value == role {
valid = true
break
}
}
if !valid {
errors = append(errors, fmt.Errorf("%s is an invalid value for argument %s", value, k))
}
return
}
}