birth_date_validator 0.1 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 637fbf5ffb1b89666920f75b64b28235675e6e05
|
4
|
+
data.tar.gz: ea0ae65a07369d83b7afb1a98a7bf2cd756f8f3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6abb63db105fd429c30576ffee9576715f8c62305b67b8711cc33a90403239221a546704e510cd9c7316461089d861d7fa739e78780407f322e75c0c81b3db79
|
7
|
+
data.tar.gz: 8239879492d557669c5186c78a7776d6384b1de59017019209b69e6b7a964f50a75fb413ba5748c58c2f5397955e991d4f5c05fefed70f882bc5a8a6f842e2b3
|
@@ -10,8 +10,8 @@
|
|
10
10
|
|
11
11
|
class BirthDateValidator < ActiveModel::EachValidator
|
12
12
|
def validate_each(record, attribute, value)
|
13
|
-
invalid = if options[:
|
14
|
-
value.year > options[:
|
13
|
+
invalid = if options[:at_least].present?
|
14
|
+
value.year > options[:at_least].year
|
15
15
|
elsif options[:less_then].present?
|
16
16
|
value.year <= options[:less_then].year
|
17
17
|
elsif options[:range].present?
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require './spec_helper'
|
2
2
|
|
3
3
|
describe BirthDateValidator do
|
4
|
-
describe 'user has to have
|
4
|
+
describe 'user has to have at least 18 years' do
|
5
5
|
context '19 years old' do
|
6
6
|
it 'is valid' do
|
7
7
|
expect(TestUserOverAge.new(birth_date: 19.years.ago)).to be_valid
|
data/spec/spec_helper.rb
CHANGED
@@ -16,7 +16,7 @@ class TestModel
|
|
16
16
|
end
|
17
17
|
|
18
18
|
class TestUserOverAge < TestModel
|
19
|
-
validates :birth_date, birth_date: {
|
19
|
+
validates :birth_date, birth_date: { at_least: 18.years.ago, message: 'come back when you will be older' }
|
20
20
|
end
|
21
21
|
|
22
22
|
class TestUserUnderAge < TestModel
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: birth_date_validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Giovanni Capuano
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|