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

Doc: validation error "type"->"kind" as part of public API for better i18n support #8346

Closed
captaincaius opened this issue Nov 15, 2019 · 0 comments
Labels
docs This issue is due to a mistake or omission in the mongoosejs.com documentation
Milestone

Comments

@captaincaius
Copy link
Contributor

Do you want to request a feature or report a bug?
feature

What is the current behavior?
The "type" property of a custom validator becomes the "kind" property of validations that fail that validation. This is GREAT, but it's not part of the public API / it's not documented.

If the current behavior is a bug, please provide the steps to reproduce.

What is the expected behavior?

  1. Make this behavior part of the public API so that it can be used on the browser for dynamically translating errors to the current language.
  2. Also document / catalog all the current internal validators' "kind"s that one should use for keys for translation.

Motivation:

Yes, #6530 added support for callback-based messages, but it's not optimal for my use case for a couple reasons:

  1. Some errors are generated on the backend (which doesn't know the frontend's current language) and sent back as a behaviorless pojo, so those ones need to be translated via "kind" anyway outside of mongoose.
  2. Frontend frameworks now have pretty robust i18n solutions (at least Angular does), and one might want to keep all localization configuration in one place.

What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
5.7.7 / 3.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This issue is due to a mistake or omission in the mongoosejs.com documentation
Projects
None yet
Development

No branches or pull requests

2 participants