Skip to content

Commit

Permalink
[feat] #7 usecase
Browse files Browse the repository at this point in the history
  • Loading branch information
Sangwook123 committed May 3, 2024
1 parent 896119f commit 7962156
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.sopt.domain.usecase

import org.sopt.model.ValidateResult
import org.sopt.model.getResult
import javax.inject.Inject

class ValidatePasswordUseCase @Inject constructor() {
operator fun invoke(password: String): ValidateResult {
if (password.isBlank()) return ValidateResult.EmptyError
return getResult(passwordPattern.matches(password))
}

companion object {
val passwordPattern = Regex(
"""^(?=.*[a-zA-Z])(?=.*[0-9])(?=.*[!@#$%^&*()-_=+{};:,<>/~`|'"\[\]\\?\.]).{8,}$"""
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.sopt.domain.usecase

import org.sopt.model.ValidateResult
import org.sopt.model.getResult
import javax.inject.Inject

class ValidatePhoneNumberUseCase @Inject constructor() {
operator fun invoke(phone: String): ValidateResult {
if (phone.isBlank()) return ValidateResult.EmptyError
return getResult(phoneNumberPattern.matches(phone))
}

companion object {
val phoneNumberPattern = Regex(
"""^01[0-9]-[0-9]{3,4}-[0-9]{4}$"""
)
}
}

0 comments on commit 7962156

Please sign in to comment.