hash_validator 0.2.6 → 0.2.7
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba6e508f307239eeb92f9fbfcdb6bc9723e7cda6
|
4
|
+
data.tar.gz: 61651a497d2399d28e0b7119051f9edb51e4a1f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98b73f5f7efa1b4af4b6c1224826d8a0bd9f9dd63a21007c76bccf773e9a812988f3dc6deb168b1796ab0706164e295c39022f2672d7be320b87a65d887208ce
|
7
|
+
data.tar.gz: 913c5a8afd5491276ab5a10dd7b0718ec26b5849ac4688bf7f49c4cc0816928abb02e7fc77aecc9daaa78f9e20cb514406133533c1a397a0efa1720d231fca07
|
@@ -18,15 +18,7 @@ class HashValidator::Validator::HashValidator < HashValidator::Validator::Base
|
|
18
18
|
errors = (errors[key] = {})
|
19
19
|
|
20
20
|
validations.each do |v_key, v_value|
|
21
|
-
|
22
|
-
|
23
|
-
# Key presence
|
24
|
-
unless value[v_key]
|
25
|
-
errors[v_key] = validator.presence_error_message
|
26
|
-
next
|
27
|
-
end
|
28
|
-
|
29
|
-
validator.validate(v_key, value[v_key], v_value, errors)
|
21
|
+
HashValidator.validator_for(v_value).validate(v_key, value[v_key], v_value, errors)
|
30
22
|
end
|
31
23
|
|
32
24
|
# Cleanup errors (remove any empty nested errors)
|
@@ -57,5 +57,13 @@ describe 'Enumerable validator' do
|
|
57
57
|
validate({ number: -5 }, validations).valid?.should be_false
|
58
58
|
end
|
59
59
|
end
|
60
|
+
|
61
|
+
describe 'nil values' do
|
62
|
+
let(:validations) {{ fruit: [ nil, :apple, :banana ] }}
|
63
|
+
|
64
|
+
it 'should validate true if a nil value is present' do
|
65
|
+
validate({ fruit: nil }, validations).valid?.should be_true
|
66
|
+
end
|
67
|
+
end
|
60
68
|
end
|
61
69
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hash_validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Brooks
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|