export const required = (message, trigger = ['blur', 'change']) => ({
	required: true,
	message,
	trigger
})

// 常用正则规则大全：https://any86.github.io/any-rule/

export const rules= {
	phone: {
		pattern: /^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/,
		message: '请填写符合要求的11位手机号',
		trigger: 'blur'
	},
	email: {
		pattern: /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/,
		message: '请填写正确的邮箱号',
		trigger: 'blur'
	},
	idCard: {
		pattern:
			/(^\d{8}(0\d|10|11|12)([0-2]\d|30|31)\d{3}$)|(^\d{6}(18|19|20)\d{2}(0[1-9]|10|11|12)([0-2]\d|30|31)\d{3}(\d|X|x)$)/,
		message: '请填写符合要求的身份证号',
		trigger: 'blur'
	},
	lettersNum: {
		pattern: /^[A-Za-z0-9]+$/,
		message: '填写内容须是字母或数字组成',
		trigger: 'blur'
	},
	number: {
		pattern: /^\d{1,}$/,
		message: '填写内容必须是纯数字',
		trigger: 'blur'
	},
	price: {
		pattern: /(?:^[1-9]([0-9]+)?(?:\.[0-9]{1,2})?$)|(?:^(?:0)$)|(?:^[0-9]\.[0-9](?:[0-9])?$)/,
		message: '只支持正数金额',
		trigger: 'blur'
	},
	decimal: {
		pattern: /^\d+(\.\d+)?$/,
		message: '只支持整数小数，不支持负数',
		trigger: 'blur'
	},
	regexNum: {
		pattern: /^[-+]?(?:\d+\.\d+|\d+)$/,
		message: '只支持数字类型',
		trigger: 'blur'
	},
  just: {
    pattern: /^[1-9]\d*$/,
    message: '只支持正数整数',
    trigger: 'blur'
  },
  zeroJust: {
    pattern: /^[0-9]\d*$/,
    message: '只支持大于等于0的整数',
    trigger: 'blur'
  },
  // 小数点2位
  decimals: {
    pattern: /^([1-9]\d*(\.\d{1,2})?|0\.(\d[1-9]|[1-9]\d))$/,
    message: '必须是正数且最多两位小数',
    trigger: 'blur'
  },
  carNum: {
    pattern: /^([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z](([DF])([A-HJ-NP-Z0-9]{5})|([0-9A-HJ-NP-Z]{5}|[0-9A-HJ-NP-Z]{4}[\u4e00-\u9fa5])))$/,
    message: '车辆号码格式错误',
    trigger: 'blur'
  }
}
