ctms/ctms-appgm/assets/graceChecker.133e534f.js
2025-04-10 23:19:13 +08:00

2 lines
2.0 KiB
JavaScript
Executable File

var r={error:"",check:function(r,e){for(var t=0;t<e.length;t++){if(!e[t].checkType)return!0;if(!e[t].name)return!0;if(!e[t].errorMsg)return!0;if(!r[e[t].name])return this.error=e[t].errorMsg,!1;switch(e[t].checkType){case"string":if(!new RegExp("^.{"+e[t].checkRule+"}$").test(r[e[t].name]))return this.error=e[t].errorMsg,!1;break;case"int":if(!new RegExp("^(-[1-9]|[1-9])[0-9]{"+e[t].checkRule+"}$").test(r[e[t].name]))return this.error=e[t].errorMsg,!1;break;case"between":if(!this.isNumber(r[e[t].name]))return this.error=e[t].errorMsg,!1;if((s=e[t].checkRule.split(","))[0]=Number(s[0]),s[1]=Number(s[1]),r[e[t].name]>s[1]||r[e[t].name]<s[0])return this.error=e[t].errorMsg,!1;break;case"betweenD":if(!/^-?[1-9][0-9]?$/.test(r[e[t].name]))return this.error=e[t].errorMsg,!1;if((s=e[t].checkRule.split(","))[0]=Number(s[0]),s[1]=Number(s[1]),r[e[t].name]>s[1]||r[e[t].name]<s[0])return this.error=e[t].errorMsg,!1;break;case"betweenF":var s;if(!/^-?[0-9][0-9]?.+[0-9]+$/.test(r[e[t].name]))return this.error=e[t].errorMsg,!1;if((s=e[t].checkRule.split(","))[0]=Number(s[0]),s[1]=Number(s[1]),r[e[t].name]>s[1]||r[e[t].name]<s[0])return this.error=e[t].errorMsg,!1;break;case"same":if(r[e[t].name]!=e[t].checkRule)return this.error=e[t].errorMsg,!1;break;case"notsame":if(r[e[t].name]==e[t].checkRule)return this.error=e[t].errorMsg,!1;break;case"email":if(!/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(r[e[t].name]))return this.error=e[t].errorMsg,!1;break;case"phoneno":if(!/^1[0-9]{10,10}$/.test(r[e[t].name]))return this.error=e[t].errorMsg,!1;break;case"zipcode":if(!/^[0-9]{6}$/.test(r[e[t].name]))return this.error=e[t].errorMsg,!1;break;case"reg":if(!new RegExp(e[t].checkRule).test(r[e[t].name]))return this.error=e[t].errorMsg,!1;break;case"in":if(-1==e[t].checkRule.indexOf(r[e[t].name]))return this.error=e[t].errorMsg,!1;break;case"notnull":if(null==r[e[t].name]||r[e[t].name].length<1)return this.error=e[t].errorMsg,!1}}return!0},isNumber:function(r){return/^-?[1-9][0-9]?.?[0-9]*$/.test(r)}};export{r as g};