dry-validation 0.9.3 → 0.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/dry/validation/error_compiler.rb +1 -2
- data/lib/dry/validation/version.rb +1 -1
- data/spec/integration/schema/nested_schemas_spec.rb +36 -0
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ba7bd2c7d9b73c611e4ef91e34a4aedf18bc38b
|
4
|
+
data.tar.gz: ad1046184040352140c06823150e09f5af13f6e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdc8ccd55d16dbf914b03c346582ed67fb22fd415bc397d468b4febd34bf15c3eafe0764c9ec0259d3ec7ea3404d935b46a67e347e27122d95949a8402cb909e
|
7
|
+
data.tar.gz: 0e6e8d169dd74bf80dda570838b89f8aa3488fb4e985b04d28d6da8ad458a0ff83fd0a798d8815dbdeb16d17c5128fd69521946bf1d7d6ff0aa0e3c7d398bd9c
|
data/CHANGELOG.md
CHANGED
@@ -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.
|
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-
|
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:
|