format_validator 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b500991685c1969b800b9cfd64a6d67c1a30de82
4
- data.tar.gz: 99a3eb3d04eb057175a128ab0ee8131f1b2d4d0f
3
+ metadata.gz: d7d32692c4abc76830fa5812fae6c2cf9f89e5fe
4
+ data.tar.gz: 82f63c5032a0d3c089ec17b5dff088eaab32fd76
5
5
  SHA512:
6
- metadata.gz: 7612cf1c270b37ece5591c486348ad9153c7ed3692f2d13cab60d09d1f71a16bfd6982d2b42efdf1793a792d45c6d1e56d7cc2566ff34ad095218821d2b08642
7
- data.tar.gz: 1318734908ef9ac010cefe9e8176a0040d0cc502d091c393e6d96ae08ce31ebccf9036acbf4283d22c3e19a8002dcb0b890e003a4c1d5393c80ccacebbf79f79
6
+ metadata.gz: 70f0341d45b93a701a98102e8c12df7be9216b1c373c89a2fffd280269f2d00642de8ccbff26d35e7f05e2bf4b24df97b3166a15c27b3bfee606bfc6cf3a09c8
7
+ data.tar.gz: 22b9f9645a9c1bda090dbf875bd83dc7a4732da3fa698a128cbd1a07fa96844b88efb4cf93760aae5b6f66f47d64a4dd01e034932233a5cc4c4ee7d45f3caa8a
data/CHANGELOG CHANGED
@@ -5,3 +5,7 @@
5
5
  ## v0.0.2
6
6
 
7
7
  * Validate date in the future
8
+
9
+ ## v0.0.3
10
+
11
+ * Minor fix for future date validator
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
@@ -1,3 +1,3 @@
1
1
  module FormatValidator
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: format_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamal El Milahi