dry-validation 0.9.3 → 0.9.4

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: d65d8862d070db6d2641c69e7077b4d2b9a97ee9
4
- data.tar.gz: 25ce604442b2886454a39e13180b52dfc498598c
3
+ metadata.gz: 7ba7bd2c7d9b73c611e4ef91e34a4aedf18bc38b
4
+ data.tar.gz: ad1046184040352140c06823150e09f5af13f6e5
5
5
  SHA512:
6
- metadata.gz: 1ff29e904cf720763e48e4e329a85e81695e9e2a17b093f1581ce46b295f4abf1116b216abb7f8ca9703b0ccd86473591dfa38d41d92b8da621c9abc729a3447
7
- data.tar.gz: 97169242904d4bd1c05efc41ef54021b10a304b2bd92ff074632a37053e81ccaab415d228c8391fb916acd73768029cf5adc065c7c29d7eb6e0e47870d1c4830
6
+ metadata.gz: bdc8ccd55d16dbf914b03c346582ed67fb22fd415bc397d468b4febd34bf15c3eafe0764c9ec0259d3ec7ea3404d935b46a67e347e27122d95949a8402cb909e
7
+ data.tar.gz: 0e6e8d169dd74bf80dda570838b89f8aa3488fb4e985b04d28d6da8ad458a0ff83fd0a798d8815dbdeb16d17c5128fd69521946bf1d7d6ff0aa0e3c7d398bd9c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # v0.9.4 2016-08-11
2
+
3
+ ### Fixed
4
+
5
+ * Error messages for sibling deeply nested schemas are nested correctly (timriley)
6
+
7
+ [Compare v0.9.3...v0.9.4](https://github.com/dryrb/dry-validation/compare/v0.9.3...v0.9.4)
8
+
1
9
  # v0.9.3 2016-07-22
2
10
 
3
11
  ### Added
@@ -57,8 +57,7 @@ module Dry
57
57
  path, other = node
58
58
 
59
59
  if opts[:path]
60
- opts[:path] << path.last
61
- visit(other, opts)
60
+ visit(other, opts.merge(path: opts[:path] + [path.last]))
62
61
  else
63
62
  visit(other, opts.merge(path: [path], schema: true))
64
63
  end
@@ -1,5 +1,5 @@
1
1
  module Dry
2
2
  module Validation
3
- VERSION = '0.9.3'.freeze
3
+ VERSION = '0.9.4'.freeze
4
4
  end
5
5
  end
@@ -1,4 +1,40 @@
1
1
  RSpec.describe Schema, 'nested schemas' do
2
+ context 'with multiple nested schemas' do
3
+ subject(:schema) do
4
+ Dry::Validation.Schema do
5
+ required(:content).schema do
6
+ required(:meta).schema do
7
+ required(:version).filled
8
+ end
9
+
10
+ required(:data).schema do
11
+ required(:city).filled
12
+ end
13
+ end
14
+ end
15
+ end
16
+
17
+ it 'passes when input is valid' do
18
+ input = {content: {meta: {version: "1.0"}, data: {city: "Canberra"}}}
19
+ expect(schema.(input)).to be_success
20
+ end
21
+
22
+ it 'fails when one sub-key is missing' do
23
+ input = {content: {data: {city: "Canberra"}}}
24
+ expect(schema.(input).messages).to eql(content: {meta: ['is missing']})
25
+ end
26
+
27
+ it 'fails when both sub-keys are missing' do
28
+ input = {content: {}}
29
+ expect(schema.(input).messages).to eql(content: {meta: ['is missing'], data: ['is missing']})
30
+ end
31
+
32
+ it 'fails when the deeply nested keys are invalid' do
33
+ input = {content: {meta: {version: ""}, data: {city: ""}}}
34
+ expect(schema.(input).messages).to eql(content: {meta: {version: ["must be filled"]}, data: {city: ["must be filled"]}})
35
+ end
36
+ end
37
+
2
38
  context 'with a 2-level deep schema' do
3
39
  subject(:schema) do
4
40
  Dry::Validation.Schema do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry-validation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Holland
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-07-22 00:00:00.000000000 Z
12
+ date: 2016-08-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: concurrent-ruby
@@ -483,4 +483,3 @@ test_files:
483
483
  - spec/unit/schema/rule_spec.rb
484
484
  - spec/unit/schema/value_spec.rb
485
485
  - spec/unit/schema_spec.rb
486
- has_rdoc: