From 2aaff874e08d93f540e99cf17664f72b800c7888 Mon Sep 17 00:00:00 2001 From: Beorn Facchini Date: Sat, 5 Oct 2024 18:12:19 +1000 Subject: [PATCH] Update name validation. --- cmd/prompt.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/prompt.go b/cmd/prompt.go index 1d47183..b603777 100644 --- a/cmd/prompt.go +++ b/cmd/prompt.go @@ -28,7 +28,7 @@ import ( var ( validEnvName = regexp.MustCompile(`^[A-Z0-9-_]+$`) - validName = regexp.MustCompile(`^[a-z][a-z0-9-_]*$`) + validName = regexp.MustCompile(`^[a-z0-9]([a-z0-9-]*[a-z0-9])?$`) validPath = regexp.MustCompile(`^(/[a-zA-Z0-9-_]+)+$`) ) @@ -472,7 +472,7 @@ func validateEnvName(val interface{}) error { func validateName(val interface{}) error { if !validName.MatchString(val.(string)) { - return errors.New("Name must start with a-z followed by a-z, 0-9, dash (-) or underscore (_)") + return errors.New("Name must only contain a-z, 0-9 or dash (-), and must start and end with a-z or 0-9") } return nil }