dry-validation 0.10.1 → 0.10.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/dry/validation/message_compiler.rb +4 -0
- data/lib/dry/validation/version.rb +1 -1
- data/spec/integration/schema/using_types_spec.rb +36 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4812f30b70d5f756baf7da235b8e37e75590bdd8
|
4
|
+
data.tar.gz: c7685c3581fbcbb70f67908db92a41913ec2e411
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7d4c1f2cf92afada3081bf943098faa1bfa7e3cd86f8389b0ea184a47522ec5ee6bacd3b51a43b61fe4ec7cb0c030218e24bd755206eb3bfcf7afa30c5abd0e
|
7
|
+
data.tar.gz: 8e350c18d4d577c4b5e4c9106822d872c8c3a3a2e35f43a1f9a0d283e24a750edc41313f1385c1f1463232239a59960d0746943c71a260b63aeba35a5bde9202
|
data/CHANGELOG.md
CHANGED
@@ -151,6 +151,10 @@ module Dry
|
|
151
151
|
[visit(left, opts), visit(right, opts)].uniq
|
152
152
|
end
|
153
153
|
|
154
|
+
def visit_type(node, opts = EMPTY_OPTS)
|
155
|
+
visit(node.rule.to_ast, opts)
|
156
|
+
end
|
157
|
+
|
154
158
|
def lookup_options(arg_vals: [], input: nil)
|
155
159
|
default_lookup_options.merge(
|
156
160
|
arg_type: arg_vals.size == 1 && arg_vals[0].class,
|
@@ -82,6 +82,42 @@ RSpec.describe Dry::Validation::Schema, 'defining schema using dry types' do
|
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
|
+
context 'with a nested schema' do
|
86
|
+
subject(:schema) do
|
87
|
+
Dry::Validation.Schema do
|
88
|
+
required(:address).schema do
|
89
|
+
zip = Dry::Types['strict.string'].constrained(format: /\A[0-9]{5}(-[0-9]{4})?\z/)
|
90
|
+
|
91
|
+
required(:zip).filled(zip)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'returns success for valid input' do
|
97
|
+
expect(schema.(address: { zip: '12321' })).to be_success
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'returns failure for invalid input' do
|
101
|
+
expect(schema.(address: { zip: '12-321' })).to be_failure
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'returns messages for invalid input' do
|
105
|
+
expect(schema.(address: nil).messages).to eql(
|
106
|
+
address: ['must be a hash']
|
107
|
+
)
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'returns error messages for invalid input' do
|
111
|
+
expect(schema.(address: {}).errors).to eql(
|
112
|
+
address: { zip: ['is missing'] }
|
113
|
+
)
|
114
|
+
|
115
|
+
expect(schema.(address: { zip: '12-321' }).errors).to eql(
|
116
|
+
address: { zip: ['is in invalid format'] }
|
117
|
+
)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
85
121
|
context 'with each' do
|
86
122
|
subject(:schema) do
|
87
123
|
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.10.
|
4
|
+
version: 0.10.2
|
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-09-
|
12
|
+
date: 2016-09-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: concurrent-ruby
|