Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhanced validation function #89

Open
alejom99 opened this issue Sep 6, 2013 · 1 comment
Open

Enhanced validation function #89

alejom99 opened this issue Sep 6, 2013 · 1 comment

Comments

@alejom99
Copy link
Contributor

alejom99 commented Sep 6, 2013

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

@peruzzo
Copy link
Contributor

peruzzo commented Sep 9, 2013

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants