mongoose-beautiful-unique-validation icon indicating copy to clipboard operation
mongoose-beautiful-unique-validation copied to clipboard

Are all errors supposed to be returned?

Open germanliu opened this issue 4 years ago • 1 comments

Hi and thanks for the plugin!

From the documentation I understand that all the validation errors should come at once. However, it is returning one error only.

For example, I have two unique fields in my schema (username and email). If I try to create a document where neither username nor email are unique the response I get is only saying that the email is not unique. However if I change the email to something unique and leave the username as before, then I receive a response saying that the username is not unique.

Is this the intended behavior? Or should I be receiving one response with all the validation errors?

Thanks in advance!

germanliu avatar Jun 02 '20 01:06 germanliu

I think it is intentional, since it stops as it hits the first error it catches that is why. So it doesn't hit an error and continue to catch the rest, but just stops at the first error it reaches and throw it.

varqasim avatar Jul 22 '20 13:07 varqasim