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: ac8ccafcb67e75d6654de2d3e46e51a1175635f7
4
- data.tar.gz: 6fb2420141d983a60a776aad9fddbbf4d64800e9
3
+ metadata.gz: ba6e508f307239eeb92f9fbfcdb6bc9723e7cda6
4
+ data.tar.gz: 61651a497d2399d28e0b7119051f9edb51e4a1f9
5
5
  SHA512:
6
- metadata.gz: 5982ee15d67fa3162ba324954964c4fc69656274849a10634bb96dc9e29b05a7588c444dfd5385da0be7f855b210596f85ae918a233fb4b6276e0cc0a9cd1a6f
7
- data.tar.gz: f8e140f62b68cdc2dbb2214592a9c97cd1fc4af85d04b839240c676c0947ca14d8f57a8745ab851cd5ee62090e9602b562e0ef83c7a4b9663dd90659a574b2ec
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
- validator = HashValidator.validator_for(v_value)
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)
@@ -1,3 +1,3 @@
1
1
  module HashValidator
2
- VERSION = '0.2.6'
2
+ VERSION = '0.2.7'
3
3
  end
@@ -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.6
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-24 00:00:00.000000000 Z
11
+ date: 2013-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler