Skip to content

Enhanced validation function #89

@alejom99

Description

@alejom99

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions