How To Validate National Identity (shenaseye Melli) Of Iranian Legal Persons
I need a method to validate the National Identity of Iranian legal persons. I have National Code validation method of Iranian natural persons HERE, but now I need National ID valid
Solution 1:
Here is a function to do so:
private boolean validateNationalOrgId(String nationalNo) {
int[] MULT = {29, 27, 23, 19, 17, 29, 27, 23, 19, 17};
int length = nationalNo.length();
if (StringUtils.isNumeric(nationalNo) && length == 11) {
char[] chars = nationalNo.toCharArray();
int checkDigit = Character.getNumericValue(chars[length - 1]);
int delta = 0;
int tensPlusTwo = Character.getNumericValue(chars[length - 2]) + 2;
for (int i = 0; i < length - 1; i++) {
delta += ((Character.getNumericValue(chars[i]) + tensPlusTwo) * MULT[i]);
}
int remain = delta % 11;
remain = remain == 10 ? 0 : remain;
return remain == checkDigit;
}
return false;
}
Post a Comment for "How To Validate National Identity (shenaseye Melli) Of Iranian Legal Persons"