From bfb3fa3fcbf34464f5c37c86befb9bb7c01dc1be Mon Sep 17 00:00:00 2001 From: Weipeng Qi Date: Wed, 13 Nov 2024 18:00:36 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=9E=E5=90=8D=E8=AE=A4=E8=AF=81?= =?UTF-8?q?=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/ets/utils/ValidatorHelper.ets | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/main/ets/utils/ValidatorHelper.ets b/src/main/ets/utils/ValidatorHelper.ets index 343ec64..71df45e 100644 --- a/src/main/ets/utils/ValidatorHelper.ets +++ b/src/main/ets/utils/ValidatorHelper.ets @@ -13,4 +13,25 @@ export class ValidatorHelper { let regexp: RegExp = new RegExp('^1[0-9]{10}$'); return regexp.test(phone) } -} \ No newline at end of file + + /** + * 是否为姓名 + * @param name + * @returns + */ + public static isName(name: string) { + let regexp: RegExp = new RegExp('^[\u4e00-\u9fa50-9a-zA-Z]{1,30}$'); + return regexp.test(name) + } + + /** + * 是否为身份证号 + * @param idcardNum + * @returns + */ + public static isIdcardNum(idcardNum: string) { + let regexp: RegExp = new RegExp('(^\\d{18}$)|(^\\d{17}(\\d|X|x)$)'); + return regexp.test(idcardNum) + } +} +