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

Customize unique error message in schema #12844

Closed
2 tasks done
vkarpov15 opened this issue Dec 29, 2022 · 2 comments
Closed
2 tasks done

Customize unique error message in schema #12844

vkarpov15 opened this issue Dec 29, 2022 · 2 comments
Labels
enhancement This issue is a user-facing general improvement that doesn't fix a bug or add a new feature new feature This change adds new functionality, like a new method or class
Milestone

Comments

@vkarpov15
Copy link
Collaborator

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the feature has not already been requested

🚀 Feature Proposal

See #1225 (comment) . Should be able to specify an error message for unique: true on a given path, and have Mongoose handle that.

Motivation

No response

Example

No response

@vkarpov15 vkarpov15 added new feature This change adds new functionality, like a new method or class enhancement This issue is a user-facing general improvement that doesn't fix a bug or add a new feature labels Dec 29, 2022
@ahmedkrdzalic
Copy link

Thank you @vkarpov15 . I am happy to see that you took first steps for this request.
If you have some next steps on your mind that I could make, you can give me a suggestion. I am willing to contribute. In that time I will read contributing guidelines for this project.

@vkarpov15
Copy link
Collaborator Author

I don't have a good suggestion right now. Big problem is that unique isn't a validator, it defines an index. So we'll probably need some error handling middleware in a plugin.

@vkarpov15 vkarpov15 added this to the 7.x Unprioritized milestone Jun 12, 2023
@vkarpov15 vkarpov15 modified the milestones: 7.x Unprioritized, 8.7 Jul 23, 2024
@vkarpov15 vkarpov15 modified the milestones: 8.7, 8.8 Sep 16, 2024
@vkarpov15 vkarpov15 modified the milestones: 8.8, 8.9 Oct 21, 2024
vkarpov15 added a commit that referenced this issue Nov 25, 2024
vkarpov15 added a commit that referenced this issue Dec 3, 2024
feat: allow specifying error message override for duplicate key errors `unique: true`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This issue is a user-facing general improvement that doesn't fix a bug or add a new feature new feature This change adds new functionality, like a new method or class
Projects
None yet
Development

No branches or pull requests

2 participants