valid 0.5.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/validation/rule/length.rb +4 -6
- data/lib/validation/rule/uri.rb +9 -9
- data/lib/validation/version.rb +1 -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: 3884b80fba4962cf882cfe7bb92f4ad9e8cb4477
|
4
|
+
data.tar.gz: a662f9037e89723252b6df170642da3553bdb8ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5f703039389a1d83f613ce03c546e2c15e3fb12a9a4d8a9cd7823917819b2c55211b27918f7d23627a76a23072820012cfa9191407d951482e92bc889d8ba90
|
7
|
+
data.tar.gz: b2b97e6ab86f1514779f0bfcdbef593e8ee9ba35d4f347073f616396e6ba3f57524b1ef141de8da6373caa644b0581abe52892d67d1d1f7c0898ee5a15ffc6d6
|
@@ -23,15 +23,13 @@ module Validation
|
|
23
23
|
|
24
24
|
# determines if value is valid according to the constructor params
|
25
25
|
def valid_value?(value)
|
26
|
-
valid = true
|
27
|
-
|
28
26
|
@params.each_pair do |key, param|
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
return false if key == :minimum && (value.nil? || value.length < param)
|
28
|
+
return false if key == :maximum && !value.nil? && value.length > param
|
29
|
+
return false if key == :exact && (value.nil? || value.length != param)
|
32
30
|
end
|
33
31
|
|
34
|
-
|
32
|
+
true
|
35
33
|
end
|
36
34
|
|
37
35
|
def error_key
|
data/lib/validation/rule/uri.rb
CHANGED
@@ -14,17 +14,17 @@ module Validation
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def valid_value?(uri_string)
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
17
|
+
return true if uri_string.nil?
|
18
|
+
|
19
|
+
uri = URI(uri_string)
|
20
|
+
@required_parts.each do |part|
|
21
|
+
if uri.send(part).nil? || uri.send(part).empty?
|
22
|
+
return false
|
23
23
|
end
|
24
|
-
true
|
25
|
-
rescue ::URI::InvalidURIError => e
|
26
|
-
return false
|
27
24
|
end
|
25
|
+
true
|
26
|
+
rescue ::URI::InvalidURIError
|
27
|
+
return false
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
data/lib/validation/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: valid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Bush
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|