-
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 #39 from Noostak/feat/NST-10/signUp
[Feat/NST-10] #38 회원가입 화면 작성
- Loading branch information
Showing
14 changed files
with
674 additions
and
186 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// UserUseCase.swift | ||
// Noostak_iOS | ||
// | ||
// Created by 박민서 on 2/20/25. | ||
// | ||
|
||
import RxSwift | ||
|
||
protocol UserUseCaseProtocol { | ||
func validate(name: String) -> Observable<ValidationResult> | ||
} | ||
|
||
final class UserUseCase: UserUseCaseProtocol { | ||
func validate(name: String) -> Observable<ValidationResult> { | ||
return Observable.just(SignUpValidator.validate(name: name)) | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
Noostak_iOS/Noostak_iOS/Domain/UseCase/Validator/SignUpValidator.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,27 @@ | ||
// | ||
// SignUpValidator.swift | ||
// Noostak_iOS | ||
// | ||
// Created by 박민서 on 2/20/25. | ||
// | ||
|
||
import Foundation | ||
|
||
struct SignUpValidator { | ||
static func validate(name: String) -> ValidationResult { | ||
// 1. 글자 수 제한 (1~10자) | ||
guard (1...10).contains(name.count) else { | ||
return .invalid(reason: "이름은 1~10자로 입력해야 합니다.") | ||
} | ||
|
||
// 2. 허용 문자: 영어 대소문자, 숫자, 한글, 홀자(한자) | ||
let regex = "^[A-Za-z0-9가-힣]*$" | ||
let predicate = NSPredicate(format: "SELF MATCHES %@", regex) | ||
|
||
if !predicate.evaluate(with: name) { | ||
return .invalid(reason: "띄어쓰기 및 특수문자는 사용할 수 없습니다.") | ||
} | ||
|
||
return .valid | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
Noostak_iOS/Noostak_iOS/Domain/UseCase/Validator/ValidationResult.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 @@ | ||
// | ||
// ValidationResult.swift | ||
// Noostak_iOS | ||
// | ||
// Created by 박민서 on 2/20/25. | ||
// | ||
|
||
|
||
enum ValidationResult { | ||
case valid | ||
case invalid(reason: String) | ||
} |
150 changes: 0 additions & 150 deletions
150
Noostak_iOS/Noostak_iOS/Global/Components/AppColorTextField.swift
This file was deleted.
Oops, something went wrong.
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.