@validatem/core
Version:
The last validation library you'll ever need.
13 lines (8 loc) • 594 B
JavaScript
;
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);
};