Skip to content

Commit

Permalink
Update phone.go
Browse files Browse the repository at this point in the history
  • Loading branch information
h-varmazyar authored Sep 29, 2024
1 parent c186a7f commit ee8a5b3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions phone/phone.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,21 @@ type Phone struct {
}

func GetPhoneNumberDetails(phoneNumber string) (*Phone, error) {
if r, b := isMobile(phoneNumber); b {
if r, b := IsMobile(phoneNumber); b {
return parseMobile(r, phoneNumber)
} else if r, b := isLandline(phoneNumber); b {
} else if r, b := IsLandline(phoneNumber); b {
return parseLandline(r, phoneNumber)
} else {
return nil, ErrPhoneNotValid
}
}

func isMobile(number string) (*regexp.Regexp, bool) {
func IsMobile(number string) (*regexp.Regexp, bool) {
r := regexp.MustCompile(`^(\+98|98|0098)?0?(9\d{9}$)`)
return r, r.MatchString(number)
}

func isLandline(number string) (*regexp.Regexp, bool) {
func IsLandline(number string) (*regexp.Regexp, bool) {
r := regexp.MustCompile(`^(\+98|98|0098)?0?(\d{10}$)`)
return r, r.MatchString(number)
}
Expand Down

0 comments on commit ee8a5b3

Please sign in to comment.