Newer
Older
KaiFengPC / src / views / preassess / removalRate / validate.js
@zhangdeliang zhangdeliang on 23 May 762 bytes 初始化项目
export const validate = (rule, value, callback) => {
  if (value === '') {
    let msg = '径流系数下限不能为空'
    if(rule.field === 'upValue') {
      msg = '径流系数上限不能为空'
    }
    callback(new Error(msg))
  } else {
    const reg = /^\d+(\.\d+)?$/
    if(reg.test(value)){
      if(parseFloat(value) >= 0 && parseFloat(value) <= 1) callback()
      else callback(new Error('请输入0-1的值'))
    } else {
      callback(new Error('请输入0-1的值'))
    }
  }
}

export const orderNoValidate = (rule, value, callback) => {
  if (value === '') {
    callback(new Error('排序不能为空'))
  } else {
    const reg = /^[1-9]+\d*$/
    if(reg.test(value)) callback()
    else callback(new Error('请输入正整数'))
  }
}