Commit 2a0ba6d1 by 赵增煜

增加身份证号码校验

parent f766061f
......@@ -67,8 +67,8 @@ public function add(Request $request)
$idValidator = new IdValidator();
// if (! $idValidator->isValid($data['id_card'])) {
// if( !in_array(strlen($data['id_card']),[15,18])){
if (strlen($data['id_card']) != 18) { // 身份证非必填项
// return $this->failed('身份证格式错误');
if (isset($data['id_card']) && strlen($data['id_card']) != 18) { // 身份证非必填项
return $this->failed('身份证格式错误');
}
if (is_int($data['age']) || $data['age'] <= 0) {
......@@ -115,8 +115,8 @@ public function update(Request $request)
// 验证身份证格式
$idValidator = new IdValidator();
// if (! $idValidator->isValid($id_card)) {
if (strlen($id_card) != 18) {
// return $this->failed('身份证格式错误');
if (isset($id_card) && strlen($id_card) != 18) {
return $this->failed('身份证格式错误');
}
if (is_int($age) || $age <= 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment