Gofmt
This commit is contained in:
parent
ba8cbbccea
commit
9fbae0471f
@ -3,6 +3,7 @@ package identity
|
||||
import (
|
||||
"regexp"
|
||||
)
|
||||
|
||||
// Define the regex patterns as constants
|
||||
const (
|
||||
addressRegex = `^0x[a-fA-F0-9]{40}$`
|
||||
|
@ -9,9 +9,9 @@ import (
|
||||
// Identity contains all flavors of identifiers used across stream, api and
|
||||
// client for a single agent.
|
||||
type Identity struct {
|
||||
NormalAddress string
|
||||
NormalAddress string
|
||||
ChecksumAddress string
|
||||
SessionId string
|
||||
SessionId string
|
||||
}
|
||||
|
||||
// CheckRecipient validates the recipient format based on the criteria
|
||||
|
@ -39,8 +39,7 @@ 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)
|
||||
|
@ -8,7 +8,8 @@ import (
|
||||
|
||||
// Define the regex patterns as constants
|
||||
const (
|
||||
phoneRegex = `^(?:\+254|254|0)?((?:7[0-9]{8})|(?:1[01][0-9]{7}))$`
|
||||
// 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}))$`
|
||||
)
|
||||
|
||||
// IsValidPhoneNumber checks if the given number is a valid phone number
|
||||
@ -20,7 +21,7 @@ func IsValidPhoneNumber(phonenumber string) bool {
|
||||
// FormatPhoneNumber formats a Kenyan phone number to "+254xxxxxxxx".
|
||||
func FormatPhoneNumber(phone string) (string, error) {
|
||||
if !IsValidPhoneNumber(phone) {
|
||||
return "", errors.New("invalid phone number")
|
||||
return "", errors.New("invalid phone number")
|
||||
}
|
||||
|
||||
// Remove any leading "+" and spaces
|
||||
@ -29,11 +30,11 @@ func FormatPhoneNumber(phone string) (string, error) {
|
||||
|
||||
// Replace leading "0" with "254" if present
|
||||
if strings.HasPrefix(phone, "0") {
|
||||
phone = "254" + phone[1:]
|
||||
phone = "254" + phone[1:]
|
||||
}
|
||||
// Add "+" if not already present
|
||||
if !strings.HasPrefix(phone, "254") {
|
||||
return "", errors.New("unexpected format")
|
||||
return "", errors.New("unexpected format")
|
||||
}
|
||||
|
||||
return "+" + phone, nil
|
||||
|
@ -12,7 +12,6 @@ const (
|
||||
|
||||
//Allowed incorrect PIN attempts
|
||||
AllowedPINAttempts = uint8(3)
|
||||
|
||||
)
|
||||
|
||||
// checks whether the given input is a 4 digit number
|
||||
|
Loading…
Reference in New Issue
Block a user