import { saveBtn, invInput } from './globalVar';

export const validateName = (rule: any, value: any, callback: any) => {  //商品名称的校验规则
    if (value === '') {
        callback(new Error('请输入商品名称'))
    } else if (value.length < 2) {
        callback(new Error('商品名称不能小于两位'))
        saveBtn.value = true
    } else { saveBtn.value = false }
}
export const validateIntro = (rule: any, value: any, callback: any) => { //商品简介的校验规则
    if (value === '') {
        callback(new Error('请输入商品简介'))
    } else if (value.length < 20) {
        callback(new Error('商品简介不能少于20字'))
        saveBtn.value = true
    } else { saveBtn.value = false }
}
export const validateDetail = (rule: any, value: any, callback: any) => {
    if (value === '') {
        callback(new Error('请输入商品详情'))
    } else if (value.length < 80) {
        callback(new Error('商品详情不能少于80字'))
        saveBtn.value = true
    } else { saveBtn.value = false }
}