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

Method validateRequiredWithout

lib/rules.js:148–177  ·  view source on GitHub ↗

* * @param {*} field * @param {*} value * @param {*} args

(field, value, args)

Source from the content-addressed store, hash-verified

146 * @param {*} args
147 */
148 async validateRequiredWithout(field, value, args) {
149
150 if (!Array.isArray(args)) args = [args];
151
152 if (!args.length) {
153 throw new Error('Invalid arguments supplied for field ' + field + ' in required with rule.');
154 }
155
156 let i, required = false;
157
158 for (i = 0; i < args.length; ++i) {
159
160 if (args[i] == field) {
161 continue;
162 }
163
164 if (this.isEmpty(this.validator.inputs[args[i]])) {
165 required = true;
166 break;
167 }
168 }
169
170 if (required && this.isEmpty(value)) {
171
172 return false;
173 }
174
175 return true;
176
177 }
178
179 async validateSometimes(field, value, args) {
180

Callers

nothing calls this directly

Calls 1

isEmptyMethod · 0.95

Tested by

no test coverage detected