export const matchChineseCharsNumbersEnglishAlphabets = (str: string) => {
  return str.match(/^[\u4e00-\u9fa5a-zA-Z0-9]*$/);
};

export const checkIdNumber = (rule: any, value: any, callback: any) => {
  const checkReg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
  if (!checkReg.test(value)) callback(new Error("身份证号码格式不正确！"));
  else callback();
};

export const checkCard = (rule: any, value: any, callback: any) => {
  const checkReg = /^(\d{16}|\d{17}|\d{19})$/;
  if (!checkReg.test(value)) callback(new Error("银行卡位数不正确！"));
  else callback();
};
// 校验手机号
export const checkPhone = (rule: any, value: any, callback: any) => {
  const checkReg = /^[1][3,4,5,7,8,9][0-9]{9}$/;
  if (!checkReg.test(value)) callback(new Error("手机号格式不正确！"));
  else callback();
};

export const checkVerificationCode = (rule: any, value: any, callback: any) => {
  const checkReg = /^\d{6}$/;
  if (!checkReg.test(value)) callback(new Error("请输入6位数字验证码"));
  else callback();
};

export const checkEmail = (rule: any, value: any, callback: any) => {
  const checkReg = /^.+\@.+\..+$/;
  if (!checkReg.test(value)) callback(new Error("请输入正确格式的邮箱"));
  else callback();
};
