-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from f-lab-edu/feature/SingUp
아이디 중복 확인 로직 생성
- Loading branch information
Showing
12 changed files
with
211 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
HomeCafeRecipes/HomeCafeRecipes/Data/Network/DTO/CheckEmailRespones.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// | ||
// CheckEmailRespones.swift | ||
// HomeCafeRecipes | ||
// | ||
// Created by 김건호 on 9/13/24. | ||
// | ||
|
||
import Foundation | ||
|
||
struct CheckEmailResponesDTO: Decodable { | ||
let isDuplicated: Bool | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
HomeCafeRecipes/HomeCafeRecipes/Data/Repositories/CheckEmailRepository.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// checkEmailRepository.swift | ||
// HomeCafeRecipes | ||
// | ||
// Created by 김건호 on 9/10/24. | ||
// | ||
|
||
import Foundation | ||
|
||
import RxSwift | ||
|
||
protocol CheckEmailRepository { | ||
func checkEmail(userID: String) -> Single<Bool> | ||
} | ||
|
||
final class CheckEmailRepositoryImpl: CheckEmailRepository { | ||
private let signUpPostService: SignUpService | ||
|
||
init(signUpPostService: SignUpService) { | ||
self.signUpPostService = signUpPostService | ||
} | ||
|
||
func checkEmail(userID: String) -> Single<Bool> { | ||
return signUpPostService.checkEmail(userID: userID) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
HomeCafeRecipes/HomeCafeRecipes/Domain/UseCases/CheckEmailUsecase.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// CheckEmailUsecase.swift | ||
// HomeCafeRecipes | ||
// | ||
// Created by 김건호 on 9/10/24. | ||
// | ||
|
||
import Foundation | ||
|
||
import RxSwift | ||
|
||
protocol CheckEmailUseCase { | ||
func execute(email: String) -> Single<Bool> | ||
} | ||
|
||
final class CheckEmailUseCaseImpl: CheckEmailUseCase { | ||
private let repository: CheckEmailRepository | ||
|
||
init(repository: CheckEmailRepository) { | ||
self.repository = repository | ||
} | ||
|
||
private func isValidEmail(_ email: String) -> Bool { | ||
let emailRegEx = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}" | ||
let emailPredicate = NSPredicate(format:"SELF MATCHES %@", emailRegEx) | ||
return emailPredicate.evaluate(with: email) | ||
} | ||
|
||
func execute(email: String) -> Single<Bool> { | ||
guard isValidEmail(email) else { | ||
return Single.error(NSError( | ||
domain: "InvalidEmailError", | ||
code: -1, | ||
userInfo: [NSLocalizedDescriptionKey: "잘못된 이메일 형식입니다."]) | ||
) | ||
} | ||
return repository.checkEmail(userID: email) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.