validates_formatting_of 0.6.0 → 0.6.1
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.
@@ -54,6 +54,11 @@ module ValidatesFormattingOf
|
|
54
54
|
|
55
55
|
# IP Address validation
|
56
56
|
def ip_address
|
57
|
+
warn "[DEPRECATION] The :ip_address validation for `valdiates_formatting_of` is DEPRECATED. Please update your model validations to use :ip_address_v4. This method will be removed by version 0.7.0."
|
58
|
+
ip_address_v4
|
59
|
+
end
|
60
|
+
|
61
|
+
def ip_address_v4
|
57
62
|
%r{\A(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\Z}
|
58
63
|
end
|
59
64
|
|
@@ -116,6 +116,20 @@ describe ValidatesFormattingOf::ModelAdditions do
|
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
119
|
+
describe "ip_address_v4" do
|
120
|
+
class IPAddress < SuperModel::Base
|
121
|
+
validates_formatting_of :ip, :using => :ip_address_v4
|
122
|
+
end
|
123
|
+
it "validates that the IP address provided is valid" do
|
124
|
+
IPAddress.new(:ip => '10.10.10').should_not be_valid
|
125
|
+
IPAddress.new(:ip => '999.10.10.20').should_not be_valid
|
126
|
+
IPAddress.new(:ip => '2222.22.22.22').should_not be_valid
|
127
|
+
IPAddress.new(:ip => '22.2222.22.2').should_not be_valid
|
128
|
+
IPAddress.new(:ip => '127.0.0.1').should be_valid
|
129
|
+
IPAddress.new(:ip => '132.254.111.10').should be_valid
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
119
133
|
# For clarification, NONE of the following numbers are real credit card numbers.
|
120
134
|
# They only match the pattern. These were randomly made for testing.
|
121
135
|
describe "credit_card" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: validates_formatting_of
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -111,18 +111,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
111
111
|
- - ! '>='
|
112
112
|
- !ruby/object:Gem::Version
|
113
113
|
version: '0'
|
114
|
-
segments:
|
115
|
-
- 0
|
116
|
-
hash: -3727749513764569067
|
117
114
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
115
|
none: false
|
119
116
|
requirements:
|
120
117
|
- - ! '>='
|
121
118
|
- !ruby/object:Gem::Version
|
122
119
|
version: '0'
|
123
|
-
segments:
|
124
|
-
- 0
|
125
|
-
hash: -3727749513764569067
|
126
120
|
requirements: []
|
127
121
|
rubyforge_project:
|
128
122
|
rubygems_version: 1.8.23
|