@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) internal fun validateForm(): Boolean { var isValid = true if (binding.cardNumberInput.text.toString().validateCreditCardNumber()) { binding.cardNumberLayout.error = null binding.cardNumberTitle.setTextColor(binding.root.context.getColorFromAttr(R.attr.textPrimary)) } else { isValid = false binding.cardNumberLayout.error = binding.root.context.getString(R.string.credit_cards_number_validation_error_message) binding.cardNumberTitle.setTextColor(binding.root.context.getColorFromAttr(R.attr.textWarning)) } if (binding.nameOnCardInput.text.toString().isNotBlank()) { binding.nameOnCardLayout.error = null binding.nameOnCardTitle.setTextColor(binding.root.context.getColorFromAttr(R.attr.textPrimary)) } else { isValid = false binding.nameOnCardLayout.error = binding.root.context.getString(R.string.credit_cards_name_on_card_validation_error_message) binding.nameOnCardTitle.setTextColor(binding.root.context.getColorFromAttr(R.attr.textWarning)) } return isValid }
Validates the credit card information entered by the user.