format_validator 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +4 -0
- data/README.md +1 -3
- data/lib/format_validator/future_date_validator.rb +1 -1
- data/lib/format_validator/version.rb +1 -1
- data/spec/format_validator/future_date_validator_spec.rb +6 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7d32692c4abc76830fa5812fae6c2cf9f89e5fe
|
4
|
+
data.tar.gz: 82f63c5032a0d3c089ec17b5dff088eaab32fd76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70f0341d45b93a701a98102e8c12df7be9216b1c373c89a2fffd280269f2d00642de8ccbff26d35e7f05e2bf4b24df97b3166a15c27b3bfee606bfc6cf3a09c8
|
7
|
+
data.tar.gz: 22b9f9645a9c1bda090dbf875bd83dc7a4732da3fa698a128cbd1a07fa96844b88efb4cf93760aae5b6f66f47d64a4dd01e034932233a5cc4c4ee7d45f3caa8a
|
data/CHANGELOG
CHANGED
data/README.md
CHANGED
@@ -24,10 +24,8 @@ As of today the gem validates only email, url, and zip_code.
|
|
24
24
|
validates :email, email_format: true
|
25
25
|
validates :url, url_format: true
|
26
26
|
validates :zip_code, zip_code_format: true
|
27
|
+
validates :expiration_date, future_date: true
|
27
28
|
```
|
28
|
-
## TODO
|
29
|
-
|
30
|
-
Add more validators.
|
31
29
|
|
32
30
|
## Contributing
|
33
31
|
|
@@ -2,7 +2,7 @@ module ActiveModel
|
|
2
2
|
module Validations
|
3
3
|
class FutureDateValidator < ActiveModel::EachValidator
|
4
4
|
def validate_each(object, attribute, value)
|
5
|
-
if value <= Time.now
|
5
|
+
if value.to_i <= Time.now.to_i
|
6
6
|
object.errors[attribute] << (options[:message] || 'must be in the future')
|
7
7
|
end
|
8
8
|
end
|
@@ -29,6 +29,12 @@ describe 'FutureDateValidator' do
|
|
29
29
|
subject.errors.messages.size.must_equal 1
|
30
30
|
subject.errors.messages[:expiration_date].must_equal ['must be in the future']
|
31
31
|
end
|
32
|
+
|
33
|
+
it 'should not blow up if the expirate date is nil' do
|
34
|
+
subject.valid?.must_equal false
|
35
|
+
subject.errors.messages.size.must_equal 1
|
36
|
+
subject.errors.messages[:expiration_date].must_equal ['must be in the future']
|
37
|
+
end
|
32
38
|
end
|
33
39
|
end
|
34
40
|
end
|