Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hertz315/83d4d9d54d86f83017826ec1c3e220a0 to your computer and use it in GitHub Desktop.
Save hertz315/83d4d9d54d86f83017826ec1c3e220a0 to your computer and use it in GitHub Desktop.
회원가입 로직 - 이메일 유효성 체크 Combine

회원가입 로직 - 이메일 유효성 체크 Combine

    // MARK: - 📧이메일 퍼블리셔
    @Published var email: String = ""
    @Published var emailValid: Bool = false
    @Published var emailValidCheck: Bool = false
    
        // MARK: - 이메일 유효성 체크
    func emailAdressValidCheck() {
        $email
            .map { email in
                let emailPredicate = NSPredicate(format:"SELF MATCHES %@", "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}")
                
                return emailPredicate.evaluate(with: email)
            }
            .sink { bool in
                print("\(bool)⭐️")
                self.emailValidCheck = bool
            }
            .store(in: &subscriptions)
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment