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

Is there way to add errors manually? #10

Open
ribbedcrown opened this issue Jul 30, 2015 · 2 comments
Open

Is there way to add errors manually? #10

ribbedcrown opened this issue Jul 30, 2015 · 2 comments
Labels

Comments

@ribbedcrown
Copy link
Contributor

It`ll be useful for example for Meteor Accounts error displaying:

Accounts.forgotPassword({ email: form.get('email') }, err => {
  if (err && typeof err.reason === 'string') {
    const reason = err.reason;

    if (reason.indexOf('User not found') !== -1) {
      // adding error manually
    }
      // ...
  }
});

where form is Astro.Class instance.

Maybe something similar to [Simple Schemas](https://github.com/aldeed/meteor-simple-schema#manually-adding-a-validation-error) validationContext.addInvalidKeys(errors)`.

P.S. Great work, many thanks!

@lukejagodzinski
Copy link
Owner

If don't know if in your case is it needed however it may be good feature to implement. I will probably add it in the near future. However, right now you can do it using some internal API.

form._errors.set('fieldName', 'Error message');

Right now all error messages are related with some field name. However I will be working on implementing field errors and document errors. Where document errors will be related with entire document, not particular field.

@ribbedcrown
Copy link
Contributor Author

Thank you, @jagi, this is what I need! Document errors looks useful for work with error summaries. It'll be cool feature.

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

No branches or pull requests

2 participants