Add testValue API
parent
de9b403588
commit
061123e1b4
@ -0,0 +1,12 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
const applyValidators = require("../apply-validators");
|
||||||
|
|
||||||
|
// NOTE: This will *not* give you access to either the errors or the transformed value! It's typically used for conditional logic in business logic *after* the initial validation has already taken place. This allows for reusing the entire ecosystem of Validatem validators for "does this value match format X, if yes, run this code"-type logic.
|
||||||
|
// FIXME: Put this in the documentation instead.
|
||||||
|
|
||||||
|
module.exports = function (value, rules) {
|
||||||
|
let { errors } = applyValidators(value, rules);
|
||||||
|
|
||||||
|
return (errors.length === 0);
|
||||||
|
};
|
Loading…
Reference in New Issue