在async-validator源码中,src/rule文件夹下各代码文件实现了最基础的数据校验能力,因此也可以被称为基础校验规则。 1.1 类型校验 要分析async-validator模块的实现,容笔者先从类型校验说起。 在async-validator模块中,单个校验器被定义为validator函数。该validator函数接受rule、value、callback、source、options作为参数。
order: [ {type:'string', validator: validateOrder, trigger: 'blur'} ] }
const validator = new Schema(descriptor); let model : {[key : string]:any} = {}; let validateMessage = null; // 使用中文错误提示 if (layForm.useCN) { validateMessage = Object.assign({}, cnValidateMessage, layForm.validateMessage); model[props.label||props.prop] = filedValue.value;...
输入了数字,标识不通过 解决:验证前先转为数值型 transform:(value) => $options.filters.formValidateFun(value,'number') <FormItem label="" :prop="'quantityQuotaList.' + index + '.planData'" :rules="{required: true, type: 'number', trigger: 'blur', transform:(value) => $options.filters...
validator-uniapp/src/xRadioGroup.vue' import xradio from './components/async-validator-uniapp/src/xRadio.vue' import xpicker from './components/async-validator-uniapp/src/xPicker.vue' import xtextarea from './components/async-validator-uniapp/src/xTextarea.vue' Vue.component("x-form", ...
1. 2. 3. 4. 输入了数字,标识不通过 解决:验证前先转为数值型 transform:(value) => $options.filters.formValidateFun(value,'number') <FormItem label="" :prop="'quantityQuotaList.' + index + '.planData'" :rules="{required: true, type: 'number', trigger: 'blur', transform:(value) ...