import validateXG from './validateXG'
import validate from './validate'

var isMobile = (rule, value, callback) => {
  if (value && !validateXG.isMobile(value)) {
    callback(new Error('请输入正确的电话号码'))
  } else {
    callback()
  }
}

var isPhone = (rule, value, callback) => {
  if (value && !validateXG.isPhone(value)) {
    callback(new Error('请输入正确的电话号码'))
  } else {
    callback()
  }
}

var isPhoneOrMobile = (rule, value, callback) => {
  if (value && !validateXG.isPhoneOrMobile(value)) {
    callback(new Error('请输入正确的电话号码'))
  } else {
    callback()
  }
}

var isBankNumber = (rule, value, callback) => {
  if (value && !validateXG.isBankNumber(value)) {
    callback(new Error('请输入正确的开票账号'))
  } else {
    callback()
  }
}

var isLinkMobile = (rule, value, callback) => {
  if (value && !validateXG.isLinkMobile(value)) {
    callback(new Error('请输入正确的联系人联系方式'))
  } else {
    callback()
  }
}

var isIntGtZero = (rule, value, callback) => {
  if (value && !validate.isIntGtZero(value)) {
    callback(new Error('请输入大于0整数'))
  } else {
    callback()
  }
}

var isBankNum = (rule, value, callback) => {
  if (value && !validateXG.isBankNum(value)) {
    callback(new Error('请输入正确的银行卡号'))
  } else {
    callback()
  }
}

var isEmail = (rule, value, callback) => {
  if (value && !validateXG.isEmail(value)) {
    callback(new Error('请输入正确的邮箱地址'))
  } else {
    callback()
  }
}

export default {isMobile, isPhone, isBankNumber, isLinkMobile, isIntGtZero, isBankNum, isPhoneOrMobile, isEmail}
