MCPcopy Index your code
hub / github.com/bitnbytesio/node-input-validator / addPostRule

Method addPostRule

lib/validator.js:116–137  ·  view source on GitHub ↗

* add post rule * * post rule is applied to whole input and is used to check constraints * across multiple fields * * @param rule

(rule)

Source from the content-addressed store, hash-verified

114 * @param rule
115 */
116 addPostRule(rule) {
117
118 if (typeof rule === 'function') {
119 this.postValidations.push({
120 rule: 'function',
121 params: rule,
122 values: this.inputs
123 });
124 return;
125 }
126
127 rule = rule.split(':', 2);
128 let ruleName = rule[0];
129 let ruleFields = rule[1].split(','); //there always be a list of fields
130 let values = ruleFields.reduce((acc, field) => (acc[field] = this.parseKey(field, this.inputs), acc), {});
131
132 this.postValidations.push({
133 rule: ruleName,
134 params: ruleFields,
135 values: values
136 });
137 }
138
139 /**
140 * add set of post rules

Callers 2

addPostRulesMethod · 0.95
post.jsFile · 0.80

Calls 1

parseKeyMethod · 0.95

Tested by

no test coverage detected