File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -315,6 +315,29 @@ Use "%s" in the message to have the field name or label printed in the message:
315
315
throw new Error("%s must be 'admin'.");
316
316
}
317
317
});
318
+
319
+ Validator based value on another field of the incoming source being validated
320
+
321
+ field("sport", "favorite sport").custom(function(value, source) {
322
+ if (!source.country) {
323
+ throw new error('unable to validate %s');
324
+ }
325
+
326
+ switch (source.country) {
327
+ case 'US':
328
+ if (value !=== 'baseball') {
329
+ throw new Error('America likes baseball');
330
+ }
331
+ break;
332
+
333
+ case 'UK':
334
+ if (value !=== 'football') {
335
+ throw new Error('UK likes football');
336
+ }
337
+ break;
338
+ }
339
+
340
+ });
318
341
319
342
320
343
### http.ServerRequest.prototype.form
You can’t perform that action at this time.
0 commit comments