Newer
Older
Nanping_sponge_GCYPG / src / views / preassess / removalRate / validate.js
@liyingjing liyingjing on 25 Oct 2023 762 bytes 工程预评估
  1. export const validate = (rule, value, callback) => {
  2. if (value === '') {
  3. let msg = '径流系数下限不能为空'
  4. if(rule.field === 'upValue') {
  5. msg = '径流系数上限不能为空'
  6. }
  7. callback(new Error(msg))
  8. } else {
  9. const reg = /^\d+(\.\d+)?$/
  10. if(reg.test(value)){
  11. if(parseFloat(value) >= 0 && parseFloat(value) <= 1) callback()
  12. else callback(new Error('请输入0-1的值'))
  13. } else {
  14. callback(new Error('请输入0-1的值'))
  15. }
  16. }
  17. }
  18.  
  19. export const orderNoValidate = (rule, value, callback) => {
  20. if (value === '') {
  21. callback(new Error('排序不能为空'))
  22. } else {
  23. const reg = /^[1-9]+\d*$/
  24. if(reg.test(value)) callback()
  25. else callback(new Error('请输入正整数'))
  26. }
  27. }