MCPcopy
hub / github.com/xaboy/form-create / addRule

Function addRule

packages/tiny-vue/src/components/group/component.jsx:168–185  ·  view source on GitHub ↗
(i, emit)

Source from the content-addressed store, hash-verified

166 this.cache(key, value);
167 },
168 addRule(i, emit) {
169 const rule = this.formCreateInject.form.copyRules(this.rule || []);
170 const options = this.options ? {...this.options} : {
171 submitBtn: false,
172 resetBtn: false,
173 };
174 if (this.defaultValue) {
175 if (!options.formData) options.formData = {};
176 const defVal = deepCopy(this.defaultValue);
177 extend(options.formData, this.field ? {[this.field]: defVal} : defVal);
178 }
179 this.parse && this.parse({rule, options, index: this.sort.length});
180 this.cacheRule[++this.len] = {rule, options};
181 this.sort = Object.keys(this.cacheRule);
182 if (emit) {
183 nextTick(() => this.$emit('add', rule, Object.keys(this.cacheRule).length - 1));
184 }
185 },
186 add$f(i, key, $f) {
187 this.cacheRule[key].$f = $f;
188 nextTick(() => {

Callers

nothing calls this directly

Calls 4

deepCopyFunction · 0.90
extendFunction · 0.85
nextTickFunction · 0.85
copyRulesMethod · 0.80

Tested by

no test coverage detected