private fun setPassword(value:String) { _uiState.value = uiState.value.copy(password = InputWrapper(value = value)) viewModelScope.launch(Dispatchers.IO) { when(val error = getPasswordFieldErrors()) {null -> { _uiState.value = uiState.value.copy( passErrorState = PasswordErrorState( length = false, lowerUpper = false, containsNumber = false, containsSpecial = false ) ) } else -> { _uiState.value = uiState.value.copy( passErrorState = PasswordErrorState( length = error.validLength, lowerUpper = error.validLowerUpper, containsNumber = error.validNumber, containsSpecial = error.validSpecial ) ) } } } }
Function to save the user entered password in the UI state Also handles the error state for the password requirements