Hi. I've found express-form very useful, but only for express applications. For plain objects I can use https://www.npmjs.org/package/node-validator, but it didn't use validator package, which isn't nice. I think express-form can be easily refactored into 2 packages. First one is about data validation (with chaining and all cool stuff), and the second one is about express middleware specific. Here are some thoughts:
Object validation
// create validator bundle
var v = validator(
validator.property('name').trim().toString().requred(), // alias for form.field
// other routines
);
// perform data validation
v.run(objectToValidate, function (err, data) {
// err - validation errors (same as in the middleware) or null
// data - sanitized objectToValidate
});
Express middleware
form factory for middleware will just delegate all validation specific logic to the validation module.
Hi. I've found
express-form
very useful, but only for express applications. For plain objects I can use https://www.npmjs.org/package/node-validator, but it didn't usevalidator
package, which isn't nice. I thinkexpress-form
can be easily refactored into 2 packages. First one is about data validation (with chaining and all cool stuff), and the second one is about express middleware specific. Here are some thoughts:Object validation
Express middleware
form
factory for middleware will just delegate all validation specific logic to the validation module.Any thoughts?