身份证校验规则问题
This commit is contained in:
parent
697e50b520
commit
862210f8d3
|
@ -116,9 +116,10 @@ def check_id_number(idcard):
|
|||
idcard = str(idcard)
|
||||
idcard = idcard.strip()
|
||||
idcard_list = list(idcard)
|
||||
|
||||
# 地区校验
|
||||
# if not area[(idcard)[0:2]]:
|
||||
# return False, Errors[4]
|
||||
if str(idcard[0:2]) not in area:
|
||||
return False, Errors[3]
|
||||
|
||||
# 15位身份号码检测
|
||||
if len(idcard) == 15:
|
||||
|
@ -132,7 +133,7 @@ def check_id_number(idcard):
|
|||
if re.match(ereg, idcard):
|
||||
return True, ''
|
||||
else:
|
||||
return False, Errors[2]
|
||||
return False, Errors[1]
|
||||
# 18位身份号码检测
|
||||
elif len(idcard) == 18:
|
||||
# 出生日期的合法性检查
|
||||
|
@ -163,11 +164,11 @@ def check_id_number(idcard):
|
|||
if M == idcard_list[17]: # 检测ID的校验位
|
||||
return True, ''
|
||||
else:
|
||||
return False, Errors[3]
|
||||
return False, Errors[2]
|
||||
else:
|
||||
return False, Errors[2]
|
||||
return False, Errors[1]
|
||||
else:
|
||||
return False, Errors[1]
|
||||
return False, Errors[0]
|
||||
|
||||
|
||||
def check_phone_e(phone):
|
||||
|
|
Loading…
Reference in New Issue