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

Validates Uniqueness (discussion) #38

Closed
mattconnolly opened this issue May 27, 2014 · 2 comments
Closed

Validates Uniqueness (discussion) #38

mattconnolly opened this issue May 27, 2014 · 2 comments

Comments

@mattconnolly
Copy link

Validates uniqueness appears to work, although:

  1. You need to validate the encrypted_* field which doesn't match up with form fields for display to user; and
  2. shoulda-matcher validates_uniqueness_of(:encrypted_*) doesn't seem to work.

Could this be solved by a custom validator such as "validates :field, :encrypted_uniqueness => true"

Thoughts?

@reidmorrison
Copy link
Owner

Looking at existing usages for validates it could also support an extra option in the uniqueness specifier:

  validates :name, uniqueness: {case_sensitive: true, encrypted: true}, presence: true

This does however assume that the field against which the uniqueness is being tested does not have the random_iv: true option set. The encrypted value will always be unique in that case even if the decrypted value is the same.

A pull request with such a change will be very useful, as I have no doubt others have the same need.

@reidmorrison
Copy link
Owner

If this is still needed, please send a Pull Request with the necessary features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants