Browse Source

正则验证通行证和护照

sugangqiang 2 years ago
parent
commit
3d40c0769d
1 changed files with 11 additions and 1 deletions
  1. 11 1
      app/enterprise/validate/TalentInfo.php

+ 11 - 1
app/enterprise/validate/TalentInfo.php

@@ -133,8 +133,18 @@ class TalentInfo extends Validate {
                     //return \app\common\api\IdCardApi::isValidExceptMainland($value) ?: "身份证号码不合法";
                     break;
             }
+            return "身份证号码不合法";
+        } else if ($data["card_type"] == 2) {
+            if (preg_match("/^[a-zA-Z0-9]{6,10}$/", $value) || preg_match("/^([0-9]{8}|[0-9]{10})$/", $value)) {
+                return true;
+            }
+            return "通行证号码不合法";
+        } else {
+            if (preg_match("/^([a-zA-z]|[0-9]){5,17}$/", $value)) {
+                return true;
+            }
+            return "护照号码不合法";
         }
-        return "身份证号码不合法";
     }
 
     protected function checkRangeDate($value, $rule, $data = []) {