Compare commits

..

No commits in common. "master" and "alias-period" have entirely different histories.

6 changed files with 10 additions and 12 deletions

View File

@ -3,7 +3,6 @@ package identity
import (
"regexp"
)
// Define the regex patterns as constants
const (
addressRegex = `^0x[a-fA-F0-9]{40}$`

View File

@ -5,7 +5,7 @@ import (
)
const (
aliasRegex = `^(?i)[a-z][a-z0-9]*(\.[a-z0-9]+)*$`
aliasRegex = `^[a-zA-Z0-9]+(\.[a-zA-Z0.9]+)*$`
)
// IsValidAlias checks if the alias is a valid alias format

View File

@ -39,7 +39,8 @@ func CalculateAgeWithYOB(yob int) int {
return currentYear - yob
}
// IsValidYob checks if the provided yob can be considered valid
//IsValidYob checks if the provided yob can be considered valid
func IsValidYOb(yob string) bool {
currentYear := time.Now().Year()
yearOfBirth, err := strconv.ParseInt(yob, 10, 64)

View File

@ -8,10 +8,7 @@ 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.
// 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})$`
phoneRegex = `^(?:\+254|254|0)?((?:7[0-9]{8})|(?:1[01][0-9]{7}))$`
)
// IsValidPhoneNumber checks if the given number is a valid phone number

View File

@ -12,6 +12,7 @@ const (
//Allowed incorrect PIN attempts
AllowedPINAttempts = uint8(3)
)
// checks whether the given input is a 4 digit number