normaize account input
All checks were successful
Auto Tag on Version Change / check-version (push) Successful in 3s
All checks were successful
Auto Tag on Version Change / check-version (push) Successful in 3s
This commit is contained in:
@@ -256,7 +256,7 @@ class TransferFragment : Fragment() {
|
||||
Toast.makeText(requireContext(), R.string.transfer_select_source_first, Toast.LENGTH_SHORT).show()
|
||||
return
|
||||
}
|
||||
val accountNumber = binding.etTo.text?.toString()?.trim() ?: ""
|
||||
val accountNumber = AccountInputParser.normalize(binding.etTo.text?.toString()?.trim() ?: "")
|
||||
if (accountNumber.isBlank()) {
|
||||
Toast.makeText(requireContext(), R.string.transfer_enter_account_first, Toast.LENGTH_SHORT).show()
|
||||
return
|
||||
|
||||
@@ -11,6 +11,21 @@ object AccountInputParser {
|
||||
UNKNOWN
|
||||
}
|
||||
|
||||
/**
|
||||
* Strip spaces and remove a 960/+960 country code prefix, but only when
|
||||
* the stripped result is exactly 7 digits (so "9603456" is left intact).
|
||||
*/
|
||||
fun normalize(input: String): String {
|
||||
var s = input.replace(" ", "")
|
||||
val stripped = when {
|
||||
s.startsWith("+960") -> s.removePrefix("+960")
|
||||
s.startsWith("960") -> s.removePrefix("960")
|
||||
else -> null
|
||||
}
|
||||
if (stripped != null && stripped.matches(Regex("^\\d{7}$"))) s = stripped
|
||||
return s
|
||||
}
|
||||
|
||||
fun detect(input: String): InputType {
|
||||
val s = input.trim()
|
||||
return when {
|
||||
|
||||
Reference in New Issue
Block a user