ANDROIDSTUDYCHANNEL Telegram 3222
fun validateMelliCode(melliCode: String): Boolean {
val identicalDigits = arrayOf("0000000000", "1111111111", "2222222222", "3333333333", "4444444444", "5555555555", "6666666666", "7777777777", "8888888888", "9999999999")
return when {
melliCode.trim { it <= ' ' }.isEmpty() -> { false }
melliCode.length != 10 -> { false }
Arrays.asList(identicalDigits).contains(melliCode) -> { false }
else -> {
var sum = 0
for (i in 0..8) {
sum += Character.getNumericValue(melliCode[i]) * (10 - i)
}
val lastDigit: Int
val divideRemaining = sum % 11
lastDigit = if (divideRemaining < 2) {
divideRemaining
} else {
11 - divideRemaining
}
Character.getNumericValue(melliCode[9]) == lastDigit
}
}
}


سورس کد تشخیص صحت کد ملی برای زبان کاتلین

برای استفاده کافی به این شکل تابع را فراخوانی کنید :
if(validateMelliCode(binding?.EtMeli?.text.toString())){
معتبر
}else{
نامعتبر
}

@AndroidStudyChannel



tgoop.com/AndroidStudyChannel/3222
Create:
Last Update:

fun validateMelliCode(melliCode: String): Boolean {
val identicalDigits = arrayOf("0000000000", "1111111111", "2222222222", "3333333333", "4444444444", "5555555555", "6666666666", "7777777777", "8888888888", "9999999999")
return when {
melliCode.trim { it <= ' ' }.isEmpty() -> { false }
melliCode.length != 10 -> { false }
Arrays.asList(identicalDigits).contains(melliCode) -> { false }
else -> {
var sum = 0
for (i in 0..8) {
sum += Character.getNumericValue(melliCode[i]) * (10 - i)
}
val lastDigit: Int
val divideRemaining = sum % 11
lastDigit = if (divideRemaining < 2) {
divideRemaining
} else {
11 - divideRemaining
}
Character.getNumericValue(melliCode[9]) == lastDigit
}
}
}


سورس کد تشخیص صحت کد ملی برای زبان کاتلین

برای استفاده کافی به این شکل تابع را فراخوانی کنید :
if(validateMelliCode(binding?.EtMeli?.text.toString())){
معتبر
}else{
نامعتبر
}

@AndroidStudyChannel

BY 🔴 ANDROID PROGRAMMING CHANNEL


Share with your friend now:
tgoop.com/AndroidStudyChannel/3222

View MORE
Open in Telegram


Telegram News

Date: |

Just as the Bitcoin turmoil continues, crypto traders have taken to Telegram to voice their feelings. Crypto investors can reduce their anxiety about losses by joining the “Bear Market Screaming Therapy Group” on Telegram. Telegram channels enable users to broadcast messages to multiple users simultaneously. Like on social media, users need to subscribe to your channel to get access to your content published by one or more administrators. Choose quality over quantity. Remember that one high-quality post is better than five short publications of questionable value. Judge Hui described Ng as inciting others to “commit a massacre” with three posts teaching people to make “toxic chlorine gas bombs,” target police stations, police quarters and the city’s metro stations. This offence was “rather serious,” the court said. End-to-end encryption is an important feature in messaging, as it's the first step in protecting users from surveillance.
from us


Telegram 🔴 ANDROID PROGRAMMING CHANNEL
FROM American