Files
qhmes/web-dist/js/index-B9aO0c-2-CpOxyGeC.js
2026-06-16 18:19:57 +08:00

2 lines
645 B
Java

function r(s,a){if(/^[0-9]/.test(s))return{passed:!1,message:"不能以数字开头"};const{allowDot:f=!1}=a!=null?a:{};if(f){if(/^\./.test(s))return{passed:!1,message:"不能以小数点开头"};if(/\.$/.test(s))return{passed:!1,message:"不能以小数点结尾"};if(/\.{2}/.test(s))return{passed:!1,message:"不能连续出现小数点"}}let e="a-zA-Z_\\u4e00-\\u9fa5",t=["字母","数字","下划线","中文"];f&&(e+="\\.",t.splice(3,0,"小数点"),e+="\\[\\]",t.splice(3,0,"英文中括号"));const l=`^[${e}][0-9${e}]*$`;return new RegExp(l).test(s)?{passed:!0,message:""}:{passed:!1,message:"只能包含"+t.join("")}}export{r as f};