/src/utils/validate.js 

export const validatePass = (rule, value, callback) => {
  var regex = new RegExp('(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[^a-zA-Z0-9]).{6,30}');
  if (!regex.test(value)) {
    callback(new Error('密码不能少于6位,且包含大写字母、小写字母、数字、特殊符号'))
  } else {
    callback()
  }
};

组件中使用 

import { validatePass } from '@/utils/validate'

pass: '',
rules: {
  pass: [
    { required: true,validator: validatePass, trigger: 'blur' }
  ]
}

 

 

 

Logo

前往低代码交流专区

更多推荐