mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-16 10:30:08 +00:00
18 lines
497 B
Swift
18 lines
497 B
Swift
import Foundation
|
|
import TelegramCorePrivateModule
|
|
|
|
private let phoneNumberUtil = NBPhoneNumberUtil()
|
|
|
|
public func formatPhoneNumber(_ string: String) -> String {
|
|
do {
|
|
let number = try phoneNumberUtil.parse("+" + string, defaultRegion: nil)
|
|
return try phoneNumberUtil.format(number, numberFormat: .INTERNATIONAL)
|
|
} catch _ {
|
|
return string
|
|
}
|
|
}
|
|
|
|
public func isViablePhoneNumber(_ string: String) -> Bool {
|
|
return phoneNumberUtil.isViablePhoneNumber(string)
|
|
}
|