add user management functionality with OTP verification and consent handling, DI introduced
This commit is contained in:
19
internal/phoneutil/phoneutil.go
Normal file
19
internal/phoneutil/phoneutil.go
Normal file
@ -0,0 +1,19 @@
|
||||
package phoneutil
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/nyaruka/phonenumbers"
|
||||
)
|
||||
|
||||
func ParseAndFormatPhoneNumber(phoneNumber string) (string, error) {
|
||||
parsedNumber, err := phonenumbers.Parse(phoneNumber, "RU")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
result := phonenumbers.Format(parsedNumber, phonenumbers.E164)
|
||||
if result == "" {
|
||||
return "", errors.New("failed to format phone number")
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
Reference in New Issue
Block a user