From bb314d725ca50f2053b21e177cad519bbcdd494d Mon Sep 17 00:00:00 2001 From: alfred-mk Date: Thu, 17 Apr 2025 14:00:40 +0300 Subject: [PATCH 1/2] updated the phone regex to enforce strictness --- phone/phone.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/phone/phone.go b/phone/phone.go index 3f18ad5..b6ea181 100644 --- a/phone/phone.go +++ b/phone/phone.go @@ -9,7 +9,9 @@ import ( // Define the regex patterns as constants const ( // TODO: This should rather use a phone package to determine whether valid phone number for any region. - phoneRegex = `^(?:\+254|254|0)?((?:7[0-9]{8})|(?:1[01][0-9]{7}))$` + // Kenyan phone numbers: must be exactly 10 digits (07XXXXXXXX or 01XXXXXXXX) when starting with 0 + // Or start with 254 / +254 and still follow the same pattern + phoneRegex = `^(?:\+254|254|0)(7\d{8}|1[01]\d{7})$` ) // IsValidPhoneNumber checks if the given number is a valid phone number From 57d8b98212d3d3ac573f7974d3ac1742a9cf2de1 Mon Sep 17 00:00:00 2001 From: alfred-mk Date: Thu, 17 Apr 2025 14:01:38 +0300 Subject: [PATCH 2/2] updated the alias regex to only pass proper alphanumeric, dot-separated aliases --- identity/alias.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/identity/alias.go b/identity/alias.go index 0971c48..81a0a31 100644 --- a/identity/alias.go +++ b/identity/alias.go @@ -5,7 +5,7 @@ import ( ) const ( - aliasRegex = `^[a-zA-Z0-9]+(\.[a-zA-Z0.9]+)*$` + aliasRegex = `^(?i)[a-z][a-z0-9]*(\.[a-z0-9]+)*$` ) // IsValidAlias checks if the alias is a valid alias format