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

Expand unique validations with scoped and case-insensitive #436

Closed
caspiano opened this issue Dec 31, 2020 · 2 comments
Closed

Expand unique validations with scoped and case-insensitive #436

caspiano opened this issue Dec 31, 2020 · 2 comments

Comments

@caspiano
Copy link

Allow uniqueness validations scoped by other fields on the model.
Additionally, allow case-insensitive uniqueness validations.

Usage:

class Post < Granite::Base
  connection mysql

  column id : Int64, primary: true
  column title : String
  column year : Int32

  validate_uniqueness(
     :title,
     scope: :year,           # Scope can also accept an array of fields
     case_insensitive: false # Default to strict case sensitivity
  )
end
@Blacksmoke16
Copy link
Contributor

Related #358.

@crimson-knight
Copy link
Member

I'm going to close this since it's tightly related to the RFC issue already cited. I think the recommendation makes sense and will naturally come about during the validation improvement process.

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

3 participants