aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/util
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@vidhukant.com>2025-10-12 23:30:08 +0530
committerVidhu Kant Sharma <vidhukant@vidhukant.com>2025-10-12 23:30:08 +0530
commit327a32f563394f92313e4a751515d69d90f4e7f5 (patch)
tree9b49fd41ac852fa459b623f7fbe7c79aaac24418 /util
parent029fe2c7a3532bc3bf435f257cdade240c8f3568 (diff)
formatted code
Diffstat (limited to 'util')
-rw-r--r--util/validators.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/util/validators.go b/util/validators.go
index c180daf..d6eb929 100644
--- a/util/validators.go
+++ b/util/validators.go
@@ -18,12 +18,13 @@
package util
import (
- "regexp"
"net/mail"
"net/url"
+ "regexp"
)
var phoneRegex, gstinRegex *regexp.Regexp
+
func init() {
phoneRegex = regexp.MustCompile(`^(?:(?:\(?(?:00|\+)([1-4]\d\d|[1-9]\d?)\)?)?[\-\.\ \\\/]?)?((?:\(?\d{1,}\)?[\-\.\ \\\/]?){0,})(?:[\-\.\ \\\/]?(?:#|ext\.?|extension|x)[\-\.\ \\\/]?(\d+))?$`)
gstinRegex = regexp.MustCompile(`^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}Z[0-9A-Z]{1}$`)
@@ -34,7 +35,7 @@ func ValidateEmail(email string) bool {
if err != nil {
return false
}
- return true
+ return true
}
func ValidateWebsite(website string) bool {
@@ -42,7 +43,7 @@ func ValidateWebsite(website string) bool {
if err != nil {
return false
}
- return true
+ return true
}
func ValidateGstin(gstin string) bool {
@@ -50,5 +51,5 @@ func ValidateGstin(gstin string) bool {
}
func ValidatePhone(phone string) bool {
- return phoneRegex.MatchString(phone)
+ return phoneRegex.MatchString(phone)
}