ValidationUtil.js 794 B

12345678910111213141516171819202122232425262728293031
  1. import StringUtil from './StringUtil.js';
  2. import ObjectUtil from './ObjectUtil.js';
  3. const carNoReg = /^(([\u4e00-\u9fa5][a-zA-Z]|[\u4e00-\u9fa5]{2}\d{2}|[\u4e00-\u9fa5]{2}[a-zA-Z])[-]?|([wW][Jj][\u4e00-\u9fa5]{1}[-]?)|([a-zA-Z]{2}))([A-Za-z0-9]{5}|[DdFf][A-HJ-NP-Za-hj-np-z0-9][0-9]{4}|[0-9]{5}[DdFf])$/;
  4. export default class ValidationUtil {
  5. /**是否为身份证
  6. * @param {Object} value
  7. */
  8. static idCard(value)
  9. {
  10. let reg = /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/
  11. if (StringUtil.length(value) == 18 && reg.test(value))
  12. {
  13. return true
  14. }
  15. return false
  16. }
  17. static carNo(value)
  18. {
  19. return StringUtil.length(value) > 0 && carNoReg.test(value);
  20. }
  21. static tel(value)
  22. {
  23. return StringUtil.length(value) == 11
  24. }
  25. }