Skip to content

Commit

Permalink
Update azurerm/internal/services/network/validate.go
Browse files Browse the repository at this point in the history
Co-Authored-By: Steve <[email protected]>
  • Loading branch information
yves-vogl and jackofallops authored Apr 16, 2020
1 parent f9fa19b commit f88b9c6
Showing 1 changed file with 2 additions and 24 deletions.
26 changes: 2 additions & 24 deletions azurerm/internal/services/network/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,30 +153,8 @@ func ValidateRouteTableName(v interface{}, k string) (warnings []string, errors

func ValidateRouteName(v interface{}, k string) (warnings []string, errors []error) {
value := v.(string)
if !regexp.MustCompile(`^[a-zA-Z_0-9.-]+$`).MatchString(value) {
errors = append(errors, fmt.Errorf(
"only word characters, numbers, underscores, periods, and hyphens allowed in %q: %q",
k, value))
}

if len(value) > 80 {
errors = append(errors, fmt.Errorf(
"%q cannot be longer than 80 characters: %q", k, value))
}

if len(value) == 0 {
errors = append(errors, fmt.Errorf(
"%q cannot be an empty string: %q", k, value))
}
if !regexp.MustCompile(`[a-zA-Z0-9_]$`).MatchString(value) {
errors = append(errors, fmt.Errorf(
"%q must end with a word character, number, or underscore: %q", k, value))
}

if !regexp.MustCompile(`^[a-zA-Z0-9]`).MatchString(value) {
errors = append(errors, fmt.Errorf(
"%q must start with a word character or number: %q", k, value))
if !regexp.MustCompile(`^[a-zA-Z0-9][a-zA-Z0-9_.-]{0,78}[a-zA-Z0-9_]?$`).MatchString(value) {
errors = append(errors, fmt.Errorf("%q should be between 1 and 80 characters, start with an alphanumeric, end with an alphanumeric or underscore and can contain alphanumerics, underscores, periods, and hyphens", k))
}

return warnings, errors
}

0 comments on commit f88b9c6

Please sign in to comment.