private fun validateUserInformationScreen( errorTypeForFirst: ErrorType? = null, errorTypeForLast: ErrorType? = null ): UserInformationErrors? { val firstNameValid = if (errorTypeForFirst == null) { InputValidator.checkIfFieldRequired(uiState.value.firstName.value ?: "", true) } else { InputValidator.getDqmErrorIdOrNull(errorTypeForFirst) } val lastNameValid = if (errorTypeForLast == null) { InputValidator.checkIfFieldRequired(uiState.value.lastName.value ?: "", true) } else { InputValidator.getDqmErrorIdOrNull(errorTypeForLast) } return if (firstNameValid == null && lastNameValid == null) { null } else { UserInformationErrors( firstNameErrorId = firstNameValid, lastNameErrorId = lastNameValid ) } }
This function validates the information on the UserInformationScreen. If input validates fails for any of the fields, this functions assigns the error strings to be shown by the UI