Skip to content

Commit

Permalink
[FIX/#152] 회원가입 입력 로직
Browse files Browse the repository at this point in the history
  • Loading branch information
leeeyubin committed Jul 19, 2024
1 parent eb5861e commit f666c03
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fun TerningBasicTextField(
BasicTextField(
value = value,
onValueChange = {
if (maxTextLength == null || it.length <= maxTextLength) {
if (maxTextLength == null || it.length <= maxTextLength + 1) {
onValueChange(it)
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,15 @@ class SignUpViewModel @Inject constructor(

fun isInputValid(name: String) {
val nameErrorRegex = Regex(NAME_ERROR)
val trimmedName = if (name.length > MAX_LENGTH) name.substring(0, MAX_LENGTH) else name
// val outOfBoundName = if(name.length > MAX_LENGTH + 1) name.substring(0, MAX_LENGTH) else name
var trimmedName : String = ""
var trimmedNameOutOfBound : String = ""
var outOfBoundName : Boolean = false
if(name.length > MAX_LENGTH) {
trimmedName = name.substring(0, MAX_LENGTH)
trimmedNameOutOfBound = name.substring(0, MAX_LENGTH + 1)
outOfBoundName = true
}else trimmedName = name

when {
nameErrorRegex.containsMatchIn(trimmedName) -> _state.value = _state.value.copy(
Expand All @@ -55,6 +63,15 @@ class SignUpViewModel @Inject constructor(
isButtonValid = false
)

outOfBoundName -> _state.value = _state.value.copy(
name = trimmedNameOutOfBound,
drawLineColor = WarningRed,
helper = R.string.sign_up_helper,
helperIcon = R.drawable.ic_sign_up_error,
helperColor = WarningRed,
isButtonValid = false
)

else -> _state.value = _state.value.copy(
name = trimmedName,
drawLineColor = TerningMain,
Expand Down

0 comments on commit f666c03

Please sign in to comment.