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

Unique validation should not bypass during updates #9

Open
serkandurusoy opened this issue Jul 22, 2015 · 4 comments
Open

Unique validation should not bypass during updates #9

serkandurusoy opened this issue Jul 22, 2015 · 4 comments
Labels

Comments

@serkandurusoy
Copy link

According to https://github.com/jagi/meteor-astronomy-validators/blob/master/lib/validators/comparison/unique.js#L11

you are checking for uniqueness only during inserts. But updates should also apply the validation rule.

Consider a case where I want usernames to be unique.

I insert user1 and user2 and then decide that I want to update user2 and want to set it to user1 which bypasses the unique check, hence misleading.

@lukejagodzinski
Copy link
Owner

Thanks I will fix it in the next release

@serkandurusoy
Copy link
Author

While at it, could you also enhance the index definition so that we can create unique indexes?

@lukejagodzinski
Copy link
Owner

You already can create unique indexes by passing options. Read the documentation for Mongo Indexes. However I know that it should be something that is more easily accessible, so I will add unique option to definition of the field.

@serkandurusoy
Copy link
Author

Oh, I was not aware that the unique option could be passed in the indexes.options object. Thanks!

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