form.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /**
  2. * Validate v1.0.0 通用验证
  3. */
  4. import test from '@/uview-ui/libs/function/test.js'
  5. export default {
  6. // 手机号
  7. mobile: [{
  8. required: true,
  9. message: '请输入手机号',
  10. trigger: ['change', 'blur']
  11. },
  12. {
  13. validator: (rule, value, callback) => {
  14. return test.mobile(value);
  15. },
  16. message: '手机号码格式不正确',
  17. trigger: ['change', 'blur']
  18. }
  19. ],
  20. // 账户
  21. account: [{
  22. required: true,
  23. min: 5,
  24. message: '请输入账号',
  25. trigger: ['change', 'blur']
  26. }],
  27. // 短信验证码
  28. code: [{
  29. required: true,
  30. min: 4,
  31. message: '请输入验证码',
  32. trigger: ['change', 'blur']
  33. }],
  34. // 密码
  35. password: [{
  36. required: true,
  37. message: '请输入密码',
  38. trigger: ['change', 'blur']
  39. },
  40. {
  41. pattern: /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]+\S{5,12}$/,
  42. message: '需同时含有字母和数字,长度在6-12之间',
  43. trigger: ['change', 'blur']
  44. }
  45. ],
  46. // 真实姓名
  47. realName: [{
  48. required: true,
  49. message: '请输入持卡人姓名',
  50. trigger: ['change', 'blur']
  51. },
  52. {
  53. validator: (rule, value, callback) => {
  54. return test.chinese(value);
  55. },
  56. message: '请输入汉字',
  57. trigger: ['change', 'blur']
  58. }
  59. ],
  60. // 开户行
  61. bankName: [{
  62. required: true,
  63. message: '请输入开户行',
  64. trigger: ['change', 'blur']
  65. },
  66. {
  67. validator: (rule, value, callback) => {
  68. return test.chinese(value);
  69. },
  70. message: '请输入汉字',
  71. trigger: ['change', 'blur']
  72. }
  73. ],
  74. // 银行卡号
  75. bankCode: [{
  76. required: true,
  77. message: '请输入银行卡号',
  78. trigger: ['change', 'blur']
  79. },
  80. {
  81. validator: (rule, value, callback) => {
  82. return test.number(value);
  83. },
  84. message: '请输入正确账号',
  85. trigger: ['change', 'blur']
  86. }
  87. ],
  88. // 支付宝账号
  89. alipayAccount: [{
  90. required: true,
  91. message: '请输入支付账号',
  92. trigger: ['change', 'blur']
  93. },
  94. {
  95. validator: (rule, value, callback) => {
  96. let isRange = test.rangeLength(value, [6, 30]);
  97. let isAsterisk = test.contains(value, '*');
  98. return isRange && !isAsterisk;
  99. },
  100. message: '请输入正确账号',
  101. trigger: ['change', 'blur']
  102. }
  103. ],
  104. }