Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/anthonator/paranoia_uniqueness_validator
https://github.com/anthonator/paranoia_uniqueness_validator
paranoia rails rails-validations ruby
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/anthonator/paranoia_uniqueness_validator
- Owner: anthonator
- License: mit
- Created: 2012-10-09T18:38:42.000Z (about 12 years ago)
- Default Branch: main
- Last Pushed: 2024-09-08T14:10:18.000Z (2 months ago)
- Last Synced: 2024-09-28T12:04:03.717Z (about 2 months ago)
- Topics: paranoia, rails, rails-validations, ruby
- Language: Ruby
- Size: 133 KB
- Stars: 47
- Watchers: 4
- Forks: 19
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# ParanoiaUniquenessValidator
Adds `validates_uniqueness_without_deleted`.
This validator will ignore any record that has a non-null value for the
`deleted_at` field. This gem was made specifically for use with the
[Paranoia](https://github.com/radar/paranoia) gem but it can be used with any
gem that uses the `deleted_at` field for marking records as deleted.[![Gem Version](https://badge.fury.io/rb/paranoia_uniqueness_validator.png)](http://badge.fury.io/rb/paranoia_uniqueness_validator) ![ci](https://github.com/anthonator/paranoia_uniqueness_validator/workflows/ci/badge.svg) [![Coverage Status](https://coveralls.io/repos/anthonator/paranoia_uniqueness_validator/badge.png)](https://coveralls.io/r/anthonator/paranoia_uniqueness_validator) [![Code Climate](https://codeclimate.com/github/anthonator/paranoia_uniqueness_validator.png)](https://codeclimate.com/github/anthonator/paranoia_uniqueness_validator)
## Installation
Add this line to your application's Gemfile:
# Rails 7.0
gem 'paranoia_uniqueness_validator', '3.4.0'# Rails 7.1
gem 'paranoia_uniqueness_validator', '3.5.0'# Rails 7.2
gem 'paranoia_uniqueness_validator', '3.6.0'And then execute:
$ bundle
Or install it yourself as:
$ gem install paranoia_uniqueness_validator
## Configuration
This validator supports all configuration options used by the base ActiveRecord
uniqueness validator. For more information check out the [Rails API documentation](http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#method-i-validates_uniqueness_of).## Usage
```ruby
class SomeModel < ActiveRecord::Base
validates :some_field, uniqueness_without_deleted: true
end
```## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request