-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Add validateMany feature method #6910
Comments
I'm not sure I understand the problem here. You can multiple validate calls, |
We can add multiple validate, but as I know it will break at the first failure, and my suggestion is, to add a new validate method what run all validator function on the fields, even if some of them failed. Update: sometimes we want to test the min length and is the string contain specific character e.g, password. In that case, what a cool thing could be, if we can show to the user the two error in one step, Now the validate show only the first error. |
We will consider adding a similar feature for a future release. Until then, you can use something like Ramda's compose function |
Add function `SchemaType.prototype.validateAll`
Do you want to request a feature or report a bug?
Feature
What is the current behavior?
There is no way to run multiple validators on the shame field.
If the current behavior is a bug, please provide the steps to reproduce.
What is the expected behavior?
We should to be able to add multiple custom validators, and get back the result all of them.
I saw that there were some issue what reported the same, and the answer was, we can use mongoose-validator-all package. But that package have no more maintained for 1,5 years and anyway it should be supported by mongoose i think.
To prevent breaking changes, instead of overwrite the current validate system, just add a new one.
Errors:
UI:
For be able to compare fields whit others e.g password, this should to contain the document itself as in pre hooks.
The text was updated successfully, but these errors were encountered: