1234567891011121314151617181920212223242526272829303132333435363738 |
- export const simpleRequired = (message = '请输入') => {
- return {
- type: 'string',
- required: true,
- message,
- trigger: ['blur', 'change'],
- }
- }
- export const carNoRule = {
- min: 5,
- max: 8,
- message: '请输入正确的车牌号',
- }
- export const mobileRule = {
- pattern: /^1[3-9]\d{9}$/,
- transform(value) {
- return String(value);
- },
- message: '请输入正确的手机号',
- }
- export const idRule = {
- pattern: /^[1-9]\d{5}(18|19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}(\d|X|x)$/,
- transform(value) {
- return String(value);
- },
- message: '请输入正确的证件号',
- }
- export const mkRules = (fields, fun = simpleRequired) => {
- const ret = {}
- fields.forEach(d => {
- ret[d] = [fun()]
- })
- return ret
- }
|