diff options
Diffstat (limited to 'util')
-rw-r--r-- | util/validators.go | 9 |
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) } |