Newer
Older
Nanping_sponge_GCYPG / src / views / preassess / removalRate / validate.js
@liyingjing liyingjing on 25 Oct 2023 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('请输入正整数'))
  }
}