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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 95678ed889479acfad08b91569cfc0b9e86b7e45
4
- data.tar.gz: 7fbc20b57cefdf16bf094714fc0e2a73e944cbf3
3
+ metadata.gz: 3884b80fba4962cf882cfe7bb92f4ad9e8cb4477
4
+ data.tar.gz: a662f9037e89723252b6df170642da3553bdb8ec
5
5
  SHA512:
6
- metadata.gz: 148beec3403250bd30f51f47f01c9cd67cb89f387614f94bc9ef43a265539de28befc17d85fa2e5c117c2ca27095cac780118d759dd7bebc32abc89f00562d5b
7
- data.tar.gz: fcea3fa96b21ddb52186ecabf43392f9e7dc6e4179b1fb7c0c83b568d7d0e3642776705b39f1bf481a4cd8ac425e61e669ef417b290c5528c79f92613233b43b
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
- valid = false if key == :minimum && value.length < param
30
- valid = false if key == :maximum && value.length > param
31
- valid = false if key == :exact && value.length != param
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
- valid
32
+ true
35
33
  end
36
34
 
37
35
  def error_key
@@ -14,17 +14,17 @@ module Validation
14
14
  end
15
15
 
16
16
  def valid_value?(uri_string)
17
- begin
18
- uri = URI(uri_string)
19
- @required_parts.each do |part|
20
- if uri.send(part).nil? || uri.send(part).empty?
21
- return false
22
- end
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
@@ -1,3 +1,3 @@
1
1
  module Validation
2
- VERSION = '0.5.0'
2
+ VERSION = '1.0.0'
3
3
  end
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.5.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-03-16 00:00:00.000000000 Z
11
+ date: 2015-08-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: