keep edit

This commit is contained in:
edwinQQQ
2025-10-17 14:52:29 +08:00
parent 22185d799e
commit 517365879a
622 changed files with 40518 additions and 7298 deletions

View File

@@ -0,0 +1,52 @@
//
// EPLoginState.swift
// YuMi
//
// Created by AI on 2025-01-27.
//
import Foundation
/// 登录显示类型枚举
enum EPLoginDisplayType {
case id // ID + 密码
case email // 邮箱 + 验证码
case phone // 手机号 + 验证码
case emailReset // 邮箱找回密码
case phoneReset // 手机号找回密码
}
/// 登录状态验证器Phase 2 实现)
class EPLoginValidator {
/// 密码强度验证6-16位必须包含字母+数字
func validatePassword(_ password: String) -> Bool {
guard password.count >= 6 && password.count <= 16 else { return false }
let hasLetter = password.rangeOfCharacter(from: .letters) != nil
let hasDigit = password.rangeOfCharacter(from: .decimalDigits) != nil
return hasLetter && hasDigit
}
/// 邮箱格式验证
func validateEmail(_ email: String) -> Bool {
let emailRegex = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"
let emailPredicate = NSPredicate(format: "SELF MATCHES %@", emailRegex)
return emailPredicate.evaluate(with: email)
}
/// 验证码格式验证6位数字
func validateCode(_ code: String) -> Bool {
guard code.count == 6 else { return false }
return code.allSatisfy { $0.isNumber }
}
/// 手机号格式验证(简单验证)
func validatePhone(_ phone: String) -> Bool {
let phoneRegex = "^[0-9]{10,15}$"
let phonePredicate = NSPredicate(format: "SELF MATCHES %@", phoneRegex)
return phonePredicate.evaluate(with: phone)
}
}