Merge pull request #2994 from hashicorp/f-improve-elb-validation-msg

provider/aws: add value into ELB name validation message
This commit is contained in:
Paul Hinze 2015-08-13 18:04:37 -05:00
commit 89e5687d1b
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
},