rails_validations 1.1.2 → 1.1.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 +4 -4
- data/README.markdown +14 -8
- data/lib/validators/date_validator.rb +5 -1
- data/spec/spec_helper.rb +1 -0
- data/spec/validations/date_spec.rb +7 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ddd6882125ca697433e2c84a1abe00d27915a047
|
|
4
|
+
data.tar.gz: c5989625d5445cc3c945dacca0508af06326bc34
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ec30b335a30fe9d5edcb557305aba2801d7311482ae6524beed630a6c4b0a26ee445211cf911b217663d316807c73fe537468a27b7dc54e14433106e1d763ffd
|
|
7
|
+
data.tar.gz: 28d39fdf01a7018dd1497b02188016bb350fb85655c1c773695b6d673f016f5f7098b749970a5c81e2b37ccd49ddf9685f31c82a5da0ff8c901f47dbe12fe6fa
|
data/README.markdown
CHANGED
|
@@ -97,26 +97,32 @@ Currently implemented countries:
|
|
|
97
97
|
ChangeLog
|
|
98
98
|
=========
|
|
99
99
|
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
Version 1.1.3, 2014-12-03
|
|
101
|
+
-------------------------
|
|
102
|
+
- Make sure that the date validator doesn’t throw an exception if
|
|
103
|
+
`'invalid'.to_date` fails.
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
Version 1.1.2, 2014-12-01
|
|
107
|
+
-------------------------
|
|
102
108
|
- Fix typo in Dutch translation.
|
|
103
109
|
- Update some docs.
|
|
104
110
|
|
|
105
111
|
|
|
106
|
-
|
|
107
|
-
|
|
112
|
+
Version 1.1.1, 2014-10-13
|
|
113
|
+
-------------------------
|
|
108
114
|
- Fix i18n key for `phone`.
|
|
109
115
|
- Allow passing a Proc to `date` without an argument.
|
|
110
116
|
|
|
111
117
|
|
|
112
|
-
|
|
113
|
-
|
|
118
|
+
Version 1.1, 2014-10-03
|
|
119
|
+
-----------------------
|
|
114
120
|
- Make the date validation work if the column it points to is `nil`.
|
|
115
121
|
- Add documentation.
|
|
116
122
|
|
|
117
123
|
|
|
118
|
-
|
|
119
|
-
|
|
124
|
+
Version 1.0, 2014-09-05
|
|
125
|
+
-----------------------
|
|
120
126
|
- Initial release.
|
|
121
127
|
|
|
122
128
|
|
|
@@ -33,7 +33,11 @@ class DateValidator < ActiveModel::EachValidator
|
|
|
33
33
|
value = if raw_value.is_a? Fixnum
|
|
34
34
|
time.at(raw_value).to_date
|
|
35
35
|
elsif raw_value.respond_to? :to_date
|
|
36
|
-
|
|
36
|
+
begin
|
|
37
|
+
raw_value.to_date
|
|
38
|
+
rescue ArgumentError
|
|
39
|
+
false
|
|
40
|
+
end
|
|
37
41
|
else
|
|
38
42
|
false
|
|
39
43
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
|
-
require 'active_support/core_ext/date/calculations'
|
|
3
2
|
|
|
4
3
|
module ValidationsSpecHelper
|
|
5
4
|
class Date < ValidationsSpecHelper::Record
|
|
@@ -62,4 +61,11 @@ describe ValidationsSpecHelper::Date do
|
|
|
62
61
|
expect(model(Date.today.advance days: -1).valid?).to eq(true)
|
|
63
62
|
end
|
|
64
63
|
end
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
it "works with input that is not even remotely a date" do
|
|
67
|
+
with_validation 'date: true' do
|
|
68
|
+
expect(model('Yesterday, a fish nibbled my toe.')).to_not be_valid
|
|
69
|
+
end
|
|
70
|
+
end
|
|
65
71
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rails_validations
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Martin Tournoij
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-12-
|
|
11
|
+
date: 2014-12-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: actionpack
|