https://github.com/roxasshadow/birth_date_validator
Very minimal birth date validator to check if the user has the right age to sign in the website.
https://github.com/roxasshadow/birth_date_validator
Last synced: over 1 year ago
JSON representation
Very minimal birth date validator to check if the user has the right age to sign in the website.
- Host: GitHub
- URL: https://github.com/roxasshadow/birth_date_validator
- Owner: RoxasShadow
- Created: 2014-10-15T20:52:15.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2014-11-10T14:48:01.000Z (over 11 years ago)
- Last Synced: 2025-02-08T02:45:31.077Z (over 1 year ago)
- Language: Ruby
- Size: 160 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Birth date validator
Minimal birth date validator to check if the user has the right age to sign in the website.
# Usage
Add to your Gemfile the following line.
```ruby
gem 'birth_date_validator'
```
Then add the following one to your model:
```ruby
validates :birth_date, birth_date: { at_least: 18.years.ago, message: 'come back when you will be older' }
validates :birth_date, birth_date: { less_then: 18.years.ago }
validates :birth_date, birth_date: { range: 18.years.ago..30.years.ago }
BirthDateValidator.valid?(Date.parse('1995/01/24'), at_least: 18.years.ago)
```
For further informations, have a look at the specs.