validation_rules 1.0.5 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/lib/validation_rules/validation_rules.rb +9 -9
- data/lib/validation_rules/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
MDQ1Mzc5MmVhMDcwZDQ2ZTFlYjJiYmQ3ZDdmMTZiN2U5MjEyMzk0NzVlYzcy
|
10
|
-
YjhiNzRhNTg4ZDA3NGJmNTk2ZGJlYzIwN2U2MWYyMzY1M2JkN2ZkODZkZWU0
|
11
|
-
ZTZiYzE5MTQ1NTU2YTkxN2JmOWI3YjUxMTZkYjM0YWI3MWE3Nzg=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
MWIyZjI1Y2JiMGIzZjhkY2MwNTljY2MyMTcyMGIwYThkODNhZmY0ZTNmYmJk
|
14
|
-
MGU0YTJkNTdhNzcxZDIwYWJhNWU0YWQxNTlmM2E1NzJjYjM5YjI5OWJhN2Nh
|
15
|
-
NDcwODk0OGRjNTBlOWI3NDFmMGEwN2FiZjg2MzEwN2RlNDcwNjE=
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a42f97b707c421e17c607f7c041d23d1e0a9e6b6
|
4
|
+
data.tar.gz: e52cc1f2e9979a2267c23f0527903c75421724c5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 20a943a09ea6d288c835f68318c0bd7f7f7979ef4f084e5cda22dbed366a53b1ed03150effa5444d3880bc36c8e69b01f4199a5cad1a9835cd9572f8bc13c142
|
7
|
+
data.tar.gz: 0f02150443cde7fabff22ac85cfc869fdfee398e5b88b0597cd1388b648308b1fd7991fd349f227af51a8032c1ecda849f04fa2d03e67a7a5081a67cbaf46613
|
@@ -47,13 +47,13 @@ module ValidationRules
|
|
47
47
|
|
48
48
|
def self.date(value)
|
49
49
|
value =~ DATE_REGEX
|
50
|
-
end
|
50
|
+
end
|
51
51
|
|
52
52
|
def self.iso8601(value)
|
53
53
|
value =~ ISO8601_REGEX
|
54
54
|
end
|
55
55
|
|
56
|
-
def self.decimal(value, precision =
|
56
|
+
def self.decimal(value, precision = 13, scale = 2)
|
57
57
|
before, after = precision - scale, scale
|
58
58
|
value.to_s =~ /^[-+]?\d{0,#{before}}?(?:\.\d{0,#{after}})?$/
|
59
59
|
end
|
@@ -71,19 +71,19 @@ module ValidationRules
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def self.future_date(value)
|
74
|
-
value = Time.parse(value) if value.is_a? String
|
74
|
+
value = Time.parse(value) if value.is_a? String
|
75
75
|
value.to_i >= Time.now.to_i
|
76
76
|
end
|
77
77
|
|
78
78
|
def self.past_date(value)
|
79
|
-
value = Time.parse(value) if value.is_a? String
|
79
|
+
value = Time.parse(value) if value.is_a? String
|
80
80
|
value.to_i <= Time.now.to_i
|
81
81
|
end
|
82
82
|
|
83
83
|
def self.between_dates(value, date1, date2)
|
84
|
-
value = Time.parse(value) if value.is_a? String
|
85
|
-
date1 = Time.parse(date1) if date1.is_a? String
|
86
|
-
date2 = Time.parse(date2) if date2.is_a? String
|
84
|
+
value = Time.parse(value) if value.is_a? String
|
85
|
+
date1 = Time.parse(date1) if date1.is_a? String
|
86
|
+
date2 = Time.parse(date2) if date2.is_a? String
|
87
87
|
|
88
88
|
value.between?(date1, date2)
|
89
89
|
end
|
@@ -120,7 +120,7 @@ module ValidationRules
|
|
120
120
|
end
|
121
121
|
|
122
122
|
def self.min_length(value, length)
|
123
|
-
value.to_s.length >= length
|
123
|
+
value.to_s.length >= length
|
124
124
|
end
|
125
125
|
|
126
126
|
def self.numeric(value)
|
@@ -166,7 +166,7 @@ module ValidationRules
|
|
166
166
|
uri = URI.parse(value)
|
167
167
|
uri.kind_of? URI::HTTP
|
168
168
|
rescue URI::InvalidURIError
|
169
|
-
false
|
169
|
+
false
|
170
170
|
end
|
171
171
|
end
|
172
172
|
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: validation_rules
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Gotterer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 1.2.9
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.2.9
|
27
27
|
description: A collection of common validation rules
|
@@ -46,12 +46,12 @@ require_paths:
|
|
46
46
|
- lib
|
47
47
|
required_ruby_version: !ruby/object:Gem::Requirement
|
48
48
|
requirements:
|
49
|
-
- -
|
49
|
+
- - '>='
|
50
50
|
- !ruby/object:Gem::Version
|
51
51
|
version: 1.9.2
|
52
52
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
|
-
- -
|
54
|
+
- - '>='
|
55
55
|
- !ruby/object:Gem::Version
|
56
56
|
version: '0'
|
57
57
|
requirements: []
|