How to add two different verification methods in the case of vue structure

 <el-form-item label=":" class="coupon-short" prop="cpName" :inline-message="true" ref="cpName">
        <el-input v-if="form.cpType !== 2" placeholder="" v-model="form.cpName" :maxlength="20"></el-input>
        <template v-else>
          <span>{{form.cpName}}</span>
          <el-button type="text" @click="openChooseGood("chooseGood", form.checkedGood)"></el-button>
        </template>
      </el-form-item>

prop= "cpName" this check can check illegal characters

now you want to implement v-else without verifying this illegal character

how to implement

Mar.04,2021

use custom proofreading rules

data () {
    let check = (rule, value, callback) => {
        if (this.form.cpType !== 2) {
            ......cpName
            if (value === '' || ....) {
                callback(new Error(''))
            } else {
                callback()
            }
        }
        callback()
    }
    return: {
        rule: {
            cpName: [
                {validator: check , trigger: 'blur'}
            ]
        }
    }
}
Menu