diff --git a/navi-widgets/src/main/java/com/navi/naviwidgets/viewholder/RepaymentOptionLayout.kt b/navi-widgets/src/main/java/com/navi/naviwidgets/viewholder/RepaymentOptionLayout.kt index 79b0fe1b73..50f54f78aa 100644 --- a/navi-widgets/src/main/java/com/navi/naviwidgets/viewholder/RepaymentOptionLayout.kt +++ b/navi-widgets/src/main/java/com/navi/naviwidgets/viewholder/RepaymentOptionLayout.kt @@ -29,6 +29,7 @@ import com.navi.base.model.LineItem import com.navi.base.utils.BaseUtils import com.navi.base.utils.isNotNull import com.navi.base.utils.isNotNullAndNotEmpty +import com.navi.base.utils.isNull import com.navi.base.utils.orFalse import com.navi.base.utils.orElse import com.navi.design.font.FontWeightEnum @@ -461,8 +462,8 @@ constructor(context: Context, attrs: AttributeSet? = null) : ConstraintLayout(co setDefaultLabel(this.repaymentOption?.amountInput?.errorMessage?.min) return false } - - if (isValidCustomAmount.not()) { + val amount = originalText.toDoubleOrNull() + if (isValidCustomAmount.not() || amount.isNull()) { setError( this.repaymentOption?.amountInput?.errorMessage?.invalidAmount ?: RepaymentErrorMessage( @@ -477,15 +478,17 @@ constructor(context: Context, attrs: AttributeSet? = null) : ConstraintLayout(co ) return false } - val amount = originalText.toDouble() - if (amount > this.repaymentOption?.amountInput?.maxAmount.orElse(Int.MAX_VALUE)) { + if (amount != null && amount > this.repaymentOption?.amountInput?.maxAmount.orElse(Int.MAX_VALUE)) { setError(this.repaymentOption?.amountInput?.errorMessage?.max) return false - } else if (amount < this.repaymentOption?.amountInput?.minAmount.orElse(Int.MIN_VALUE)) { + } else if (amount != null && amount < this.repaymentOption?.amountInput?.minAmount.orElse( + Int.MIN_VALUE + ) + ) { setError(this.repaymentOption?.amountInput?.errorMessage?.min) return false } - showAmountInWords(amount) + amount?.let { showAmountInWords(it) } return true }