Initial commit
This commit is contained in:
16
phone/phone.go
Normal file
16
phone/phone.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package phone
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
)
|
||||
|
||||
// Define the regex patterns as constants
|
||||
const (
|
||||
phoneRegex = `^(?:\+254|254|0)?((?:7[0-9]{8})|(?:1[01][0-9]{7}))$`
|
||||
)
|
||||
|
||||
// IsValidPhoneNumber checks if the given number is a valid phone number
|
||||
func IsValidPhoneNumber(phonenumber string) bool {
|
||||
match, _ := regexp.MatchString(phoneRegex, phonenumber)
|
||||
return match
|
||||
}
|
||||
Reference in New Issue
Block a user