node-persist
node-persist copied to clipboard
Enhanced validation function
Would it be possible to enhance the validate call from Connection to also accept a list of errors? Also, create a new error object named ValidationError to replace the Error object.
...
return obj.validate(function(success, message, errors) {
if (success) {
return doModelValidation();
}
return callback(new ValidationError("Validation failed: " + message, errors));
});
...
The ValidationError object would be something like:
function ValidationError(message, errors){
this.message = message;
this.errors = errors;
}
ValidationError.prototype = new Error();
The proposal above would make it easier to get all validation errors from the Model instead of just getting one error message. I could fork the repository, make the changes and send a pull request if you think is worth it.
Thanks
+1