const passwordPat=/^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\W_]+$)(?![a-z0-9]+$)(?![a-z\W_]+$)(?![0-9\W_]+$)[a-zA-Z0-9\W_]{8,30}$/
const phonePat =/^[1][3-9][0-9]{9}$/
const cardPat = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/
const feePat = /(^[1-9]([0-9] )?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/
const bandPat = /^([1-9]{1})(\d{14}|\d{18})$/

var eqFun = (pat, msg)=>{
  return function(rule, value, callback){
    if (value === "") {
      callback(new Error(msg));
    } else if (value !== pat) {
      callback(new Error(msg));
    } else {
      callback();
    }
  }
};

export default {
    cardPat,
    phonePat,
    passwordPat,
    feePat,
    bandPat,
    passwordItem: [
        { required: true, message: "请输入密码", trigger: "blur" },
        {
          pattern: passwordPat,
          message:
            "密码为数字，小写字母，大写字母，特殊符号 至少包含三种，长度为 8 - 30位",
        }
    ],
    defaultFun: (msg) =>{
      return [
        { required: true, message: msg, trigger: "blur" },
      ]
    },
    defaultNum: (msg) =>{
      return [
        { required: true, message: msg, trigger: "blur" },
      ]
    },
    eqItem:(pat, msg)=>{
      return [
        { required: true, validator: eqFun(msg), trigger: "blur" },
      ]
    },
    bandItem: [
        { required: true, message: "请输入银行卡号", trigger: "blur" },
        {
          pattern: cardPat,
          message:"请输入正确的银行卡号",
        }
    ],
    cardItem: [
        { required: true, message: "请输入身份证号码", trigger: "blur" },
        {
          pattern: cardPat,
          message:"请输入正确的身份证号码",
        }
    ],
    phoneItem: [
        { required: true, message: "请输入手机", trigger: "blur" },
        {
          pattern: phonePat,
          message: "请输入正确的手机号码",
        }
    ]
}