forked from thijooree/android
bml to fahipay support
This commit is contained in:
@@ -5,6 +5,7 @@ object AccountInputParser {
|
||||
enum class InputType {
|
||||
MIB_ACCOUNT, // 17 digits starting with 9
|
||||
BML_ACCOUNT, // 13 digits starting with 7
|
||||
FAHIPAY_ACCOUNT, // 12 digits starting with 5
|
||||
PHONE, // 7 digits starting with 7 or 9
|
||||
NATIONAL_ID, // A followed by 6 digits
|
||||
EMAIL,
|
||||
@@ -26,11 +27,16 @@ object AccountInputParser {
|
||||
return s
|
||||
}
|
||||
|
||||
fun isMibAccount(input: String) = detect(input) == InputType.MIB_ACCOUNT
|
||||
fun isBmlAccount(input: String) = detect(input) == InputType.BML_ACCOUNT
|
||||
fun isFahipayAccount(input: String) = detect(input) == InputType.FAHIPAY_ACCOUNT
|
||||
|
||||
fun detect(input: String): InputType {
|
||||
val s = input.trim()
|
||||
return when {
|
||||
s.matches(Regex("^9\\d{16}$")) -> InputType.MIB_ACCOUNT
|
||||
s.matches(Regex("^7\\d{12}$")) -> InputType.BML_ACCOUNT
|
||||
s.matches(Regex("^5\\d{11}$")) -> InputType.FAHIPAY_ACCOUNT
|
||||
s.matches(Regex("^[79]\\d{6}$")) -> InputType.PHONE
|
||||
s.matches(Regex("^[Aa]\\d{6}$")) -> InputType.NATIONAL_ID
|
||||
s.contains("@") -> InputType.EMAIL
|
||||
|
||||
Reference in New Issue
Block a user