Skip to content

Commit a23e323

Browse files
committed
refactor: make middle name optional
1 parent d83c760 commit a23e323

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

feature/auth/src/commonMain/kotlin/org/mifos/mobile/feature/auth/registration/RegistrationViewModel.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,16 +186,15 @@ class RegistrationViewModel(
186186
*/
187187
@Suppress("ReturnCount")
188188
private fun validateName(name: String, nameType: String): ValidationResult? {
189-
if (name.isEmpty()) {
189+
if (name.isEmpty() && nameType != "middle") {
190190
return when (nameType) {
191191
"first" -> ValidationResult.Error(Res.string.feature_signup_error_first_name_empty)
192-
"middle" -> ValidationResult.Error(Res.string.feature_signup_error_middle_name_empty)
193192
"last" -> ValidationResult.Error(Res.string.feature_signup_error_last_name_empty)
194193
else -> ValidationResult.Error(Res.string.feature_signup_error_invalid_name)
195194
}
196195
}
197196

198-
if (!ValidationHelper.isValidName(name)) {
197+
if (name.isNotEmpty() && !ValidationHelper.isValidName(name)) {
199198
return ValidationResult.Error(Res.string.feature_signup_error_invalid_name)
200199
}
201200

@@ -628,10 +627,11 @@ data class SignUpState(
628627
/**
629628
* Whether the submit button should be enabled based on required fields.
630629
*/
630+
// TODO Uncomment if middle name field is mandatory
631631
val isSubmitButtonEnabled: Boolean
632632
get() = customerAccount.isNotBlank() &&
633633
firstName.isNotBlank() &&
634-
middleName.isNotBlank() &&
634+
// middleName.isNotBlank() &&
635635
lastName.isNotBlank() &&
636636
email.isNotBlank() &&
637637
password.isNotBlank() &&

0 commit comments

Comments
 (0)