fix register flow
This commit is contained in:
parent
4c9bb58a88
commit
fd87c244b9
@ -34,6 +34,16 @@ struct SDLUtil {
|
||||
}
|
||||
|
||||
return digest.map { String(format: "%02x", $0) }.joined()
|
||||
|
||||
}
|
||||
|
||||
static func isValidIdentifyContact(_ input: String) -> Bool {
|
||||
switch identifyContact(input) {
|
||||
case .email, .phone:
|
||||
true
|
||||
default:
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
static func identifyContact(_ input: String) -> ContactType {
|
||||
@ -41,7 +51,7 @@ struct SDLUtil {
|
||||
// 手机号正则(中国手机号为例,以 1 开头,11 位数字)
|
||||
let phoneRegex = /^1[3-9][0-9]{9}$/
|
||||
// 邮箱正则
|
||||
let emailRegex = /^[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$/
|
||||
let emailRegex = /^[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,64}$/
|
||||
if trimmed.wholeMatch(of: phoneRegex) != nil {
|
||||
return .phone
|
||||
} else if trimmed.wholeMatch(of: emailRegex) != nil {
|
||||
|
||||
@ -102,7 +102,7 @@ struct RegisterRequestVerifyCodeView: View {
|
||||
.buttonStyle(.borderedProminent)
|
||||
.controlSize(.large)
|
||||
.frame(width: 280)
|
||||
.disabled(username.isEmpty || isProcessing)
|
||||
.disabled(!SDLUtil.isValidIdentifyContact(username) || isProcessing)
|
||||
|
||||
Spacer()
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user