From ece7547712b208379bc327c219b8a153d855b99d Mon Sep 17 00:00:00 2001 From: baegteun Date: Fri, 16 Jun 2023 20:24:12 +0900 Subject: [PATCH] =?UTF-8?q?:recycle:=20::=20=EC=A0=95=EB=B3=B4=20=EC=9E=85?= =?UTF-8?q?=EB=A0=A5=20=ED=8E=98=EC=9D=B4=EC=A7=80=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=EB=A5=BC=20=EC=9E=85=EB=A0=A5=ED=95=A0=20?= =?UTF-8?q?=EB=95=8C=20Validation=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/Intent/InputCertificateInfoIntent.swift | 4 +++- .../Sources/Intent/InputLanguageInfoIntent.swift | 10 ++++++++-- .../Sources/Intent/InputWorkInfoIntent.swift | 7 ++++++- .../Sources/{ => Array}/Array+safe.swift | 0 .../Sources/String/String+isNotEmpty.swift | 7 +++++++ 5 files changed, 24 insertions(+), 4 deletions(-) rename Projects/Shared/FoundationUtil/Sources/{ => Array}/Array+safe.swift (100%) create mode 100644 Projects/Shared/FoundationUtil/Sources/String/String+isNotEmpty.swift diff --git a/Projects/Feature/InputCertificateInfoFeature/Sources/Intent/InputCertificateInfoIntent.swift b/Projects/Feature/InputCertificateInfoFeature/Sources/Intent/InputCertificateInfoIntent.swift index 623c37bf..2bce8b3a 100644 --- a/Projects/Feature/InputCertificateInfoFeature/Sources/Intent/InputCertificateInfoIntent.swift +++ b/Projects/Feature/InputCertificateInfoFeature/Sources/Intent/InputCertificateInfoIntent.swift @@ -1,4 +1,5 @@ import Foundation +import FoundationUtil import InputCertificateInfoFeatureInterface final class InputCertificateInfoIntent: InputCertificateInfoIntentProtocol { @@ -32,7 +33,8 @@ final class InputCertificateInfoIntent: InputCertificateInfoIntentProtocol { func nextButtonDidTap(certificates: [String]) { certificateDelegate?.completeToInputCertificate( certificates: certificates - .filter { !$0.isEmpty } + .map { $0.trimmingCharacters(in: .whitespacesAndNewlines) } + .filter { $0.isNotEmpty } ) } } diff --git a/Projects/Feature/InputLanguageInfoFeature/Sources/Intent/InputLanguageInfoIntent.swift b/Projects/Feature/InputLanguageInfoFeature/Sources/Intent/InputLanguageInfoIntent.swift index 11c48010..5821d557 100644 --- a/Projects/Feature/InputLanguageInfoFeature/Sources/Intent/InputLanguageInfoIntent.swift +++ b/Projects/Feature/InputLanguageInfoFeature/Sources/Intent/InputLanguageInfoIntent.swift @@ -1,4 +1,5 @@ import Foundation +import FoundationUtil import InputLanguageInfoFeatureInterface import Validator @@ -37,8 +38,13 @@ final class InputLanguageInfoIntent: InputLanguageInfoIntentProtocol { func completeButtonDidTap(languages: [LanguageInputModel]) { let tupledLanguages = languages - .filter { !$0.languageName.isEmpty && !$0.languageScore.isEmpty } - .map { (name: $0.languageName, score: $0.languageScore) } + .map { + ( + name: $0.languageName.trimmingCharacters(in: .whitespacesAndNewlines), + score: $0.languageScore.trimmingCharacters(in: .whitespacesAndNewlines) + ) + } + .filter { $0.isNotEmpty && $1.isNotEmpty } languageDelegate?.completeToInputLanguage(languages: tupledLanguages) } } diff --git a/Projects/Feature/InputWorkInfoFeature/Sources/Intent/InputWorkInfoIntent.swift b/Projects/Feature/InputWorkInfoFeature/Sources/Intent/InputWorkInfoIntent.swift index 81c9df7e..f7b9be71 100644 --- a/Projects/Feature/InputWorkInfoFeature/Sources/Intent/InputWorkInfoIntent.swift +++ b/Projects/Feature/InputWorkInfoFeature/Sources/Intent/InputWorkInfoIntent.swift @@ -1,6 +1,8 @@ import Foundation import InputWorkInfoFeatureInterface import StudentDomainInterface +import Validator +import FoundationUtil final class InputWorkInfoIntent: InputWorkInfoIntentProtocol { private weak var model: (any InputWorkInfoActionProtocol)? @@ -19,6 +21,8 @@ final class InputWorkInfoIntent: InputWorkInfoIntentProtocol { } func updateWorkRegion(region: String, at index: Int) { + let regexValidator = RegexValidator(pattern: "^[가-힣ㄱ-ㅎㅏ-ㅣa-zA-Z0-9]$") + guard regexValidator.validate(region) || region.isEmpty else { return } model?.updateWorkRegion(region: region, at: index) } @@ -51,7 +55,8 @@ final class InputWorkInfoIntent: InputWorkInfoIntentProtocol { formOfEmployment: state.formOfEmployment.rawValue, salary: Int(state.salary) ?? 0, workRegion: state.workRegionList - .filter { !$0.isEmpty } + .map { $0.trimmingCharacters(in: .whitespacesAndNewlines) } + .filter { $0.isNotEmpty } ) inputWorkDelegate?.completeToInputWork(input: input) } diff --git a/Projects/Shared/FoundationUtil/Sources/Array+safe.swift b/Projects/Shared/FoundationUtil/Sources/Array/Array+safe.swift similarity index 100% rename from Projects/Shared/FoundationUtil/Sources/Array+safe.swift rename to Projects/Shared/FoundationUtil/Sources/Array/Array+safe.swift diff --git a/Projects/Shared/FoundationUtil/Sources/String/String+isNotEmpty.swift b/Projects/Shared/FoundationUtil/Sources/String/String+isNotEmpty.swift new file mode 100644 index 00000000..21f2d9b4 --- /dev/null +++ b/Projects/Shared/FoundationUtil/Sources/String/String+isNotEmpty.swift @@ -0,0 +1,7 @@ +import Foundation + +public extension String { + var isNotEmpty: Bool { + !self.isEmpty + } +}