export const isUrl = (rule, value, callback) => {
  if (value === '') {
    callback()
    return
  }
  const pattern = /^(https?:\/\/)?((([a-z\d]([a-z\d-]*[a-z\d])*)\.)+[a-z]{2,}|((\d{1,3}\.){3}\d{1,3}))(\:\d+)?(\/[-a-z\d%_.~+]*)*(\?[;&a-z\d%_.~+=-]*)?(\#[-a-z\d_]*)?$/i
  if (!pattern.test(value)) {
    callback(new Error(rule.message))
  }
  callback()
}

export const isNumber = (rule, value, callback) => {
  if (value <= 0) {
    callback(new Error(rule.message))
  } else {
    callback()
  }
}
