provider/aws: add value into ELB name validation message

makes debugging these validation errors much more straightforward
This commit is contained in:
Paul Hinze 2015-08-13 16:31:18 -05:00
parent c618132085
commit 55411d692d
1 changed files with 5 additions and 4 deletions

View File

@ -32,19 +32,20 @@ func resourceAwsElb() *schema.Resource {
value := v.(string)
if !regexp.MustCompile(`^[0-9A-Za-z-]+$`).MatchString(value) {
errors = append(errors, fmt.Errorf(
"only alphanumeric characters and hyphens allowed in %q", k))
"only alphanumeric characters and hyphens allowed in %q: %q",
k, value))
}
if len(value) > 32 {
errors = append(errors, fmt.Errorf(
"%q cannot be longer than 32 characters", k))
"%q cannot be longer than 32 characters: %q", k, value))
}
if regexp.MustCompile(`^-`).MatchString(value) {
errors = append(errors, fmt.Errorf(
"%q cannot begin with a hyphen", k))
"%q cannot begin with a hyphen: %q", k, value))
}
if regexp.MustCompile(`-$`).MatchString(value) {
errors = append(errors, fmt.Errorf(
"%q cannot end with a hyphen", k))
"%q cannot end with a hyphen: %q", k, value))
}
return
},