private fun dqmStringCheckerForCompanyName(parameters: JsonObject) { viewModelScope.launch(Dispatchers.IO) { when(val result = getCountryDataUseCase.checkDqmStringChecker( body = parameters )) { is RemoteResponse.Success -> { result.value.results.forEach { // Check if the company name has errors if (it.fieldName == "ACCOUNT_NAME" && it.severity == "E" && !it.valid) { when(val value = getCompanyNameErrorsOrNull(ErrorType.Error)) { // if there are no errors then proce null -> { } //if error are there display errors else -> displayCompanyInfoErrors(value) } } else if(it.fieldName == "ACCOUNT_NAME" && it.severity == "W") { when(val value = getCompanyNameErrorsOrNull(ErrorType.Warning)) { null -> { when(val addressValidation = getAddressFieldErrorsOrNull()) { null -> { } else -> { displayCompanyInfoErrors(addressValidation) } } } else -> displayCompanyInfoErrors(value) } } else { when (val addressValidation = getAddressFieldErrorsOrNull()) { null -> { if (uiState.value.isZipCodeVerificationRequired == true) { checkZipCode() } else { } } else -> { displayCompanyInfoErrors(addressValidation) } } } } } is RemoteResponse.Failure -> { } } } }
Post DQM string checker API call is made to check the error in the registration form