From f88b9c61c90cd47c3ae8c50bdf348ca7c35bf14d Mon Sep 17 00:00:00 2001 From: Yves Vogl <39190668+yves-vogl@users.noreply.github.com> Date: Thu, 16 Apr 2020 12:57:19 +0200 Subject: [PATCH] Update azurerm/internal/services/network/validate.go Co-Authored-By: Steve <11830746+jackofallops@users.noreply.github.com> --- azurerm/internal/services/network/validate.go | 26 ++----------------- 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/azurerm/internal/services/network/validate.go b/azurerm/internal/services/network/validate.go index a16e201c20be..d8b5fb1ee5e1 100644 --- a/azurerm/internal/services/network/validate.go +++ b/azurerm/internal/services/network/validate.go @@ -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 }