dry-validation 0.9.1 → 0.9.2
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: 671e0b5c9aeccb3851d4d654e82be0d2cc0dc23c
|
4
|
+
data.tar.gz: d61862295923a7a6e4cf1dacf733606bf648c9b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d9e4a6203a141ac29630a0a38dd4c29363dd7acd094f4dba55321729d6b036275111bcaae09e1764a5df4ac41c2dfe70c26b73606307c910e6c7eb56981c165
|
7
|
+
data.tar.gz: 4439a78095b19e8e1464395eccb49bd17394fb06f9d245e7bc7576fe8c9586067f90c3b46132db56ea967f0f87abcd16425963276fc4841c9b302e7ce8a6d340
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
# v0.9.2 2016-07-13
|
2
|
+
|
3
|
+
### Fixed
|
4
|
+
|
5
|
+
* Constrained types now work with `each` macro (solnic)
|
6
|
+
* Array coercion without member type works now ie `required(:arr).maybe(:array?)` (solnic)
|
7
|
+
|
8
|
+
[Compare v0.9.1...v0.9.2](https://github.com/dryrb/dry-validation/compare/v0.9.1...v0.9.2)
|
9
|
+
|
1
10
|
# v0.9.1 2016-07-11
|
2
11
|
|
3
12
|
### Fixed
|
data/dry-validation.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.add_runtime_dependency 'dry-container', '~> 0.2', '>= 0.2.8'
|
21
21
|
spec.add_runtime_dependency 'dry-equalizer', '~> 0.2'
|
22
22
|
spec.add_runtime_dependency 'dry-logic', '~> 0.3', '>= 0.3.0'
|
23
|
-
spec.add_runtime_dependency 'dry-types', '~> 0.8', '>= 0.8.
|
23
|
+
spec.add_runtime_dependency 'dry-types', '~> 0.8', '>= 0.8.1'
|
24
24
|
|
25
25
|
spec.add_development_dependency 'bundler'
|
26
26
|
spec.add_development_dependency 'rake'
|
@@ -167,6 +167,10 @@ module Dry
|
|
167
167
|
schema_class.instance_methods.include?(name)
|
168
168
|
end
|
169
169
|
|
170
|
+
def respond_to?(name)
|
171
|
+
self.class.public_methods.include?(name)
|
172
|
+
end
|
173
|
+
|
170
174
|
private
|
171
175
|
|
172
176
|
def infer_predicates(predicates, infer_on = self)
|
@@ -175,6 +179,8 @@ module Dry
|
|
175
179
|
|
176
180
|
if name.is_a?(Schema)
|
177
181
|
infer_on.schema(name)
|
182
|
+
elsif name.respond_to?(:rule)
|
183
|
+
create_rule(name.rule.to_ast)
|
178
184
|
else
|
179
185
|
infer_on.__send__(name, *args)
|
180
186
|
end
|
@@ -240,4 +240,48 @@ RSpec.describe 'Predicates: Array' do
|
|
240
240
|
end
|
241
241
|
end
|
242
242
|
end
|
243
|
+
|
244
|
+
context 'with maybe macro' do
|
245
|
+
subject(:schema) { Dry::Validation.Form { required(:foo).maybe(:array?) } }
|
246
|
+
|
247
|
+
context 'with empty string' do
|
248
|
+
let(:input) { { 'foo' => '' } }
|
249
|
+
|
250
|
+
it 'is successful' do
|
251
|
+
expect(result).to be_successful
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
context 'with nil' do
|
256
|
+
let(:input) { { 'foo' => nil } }
|
257
|
+
|
258
|
+
it 'is successful' do
|
259
|
+
expect(result).to be_successful
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
context 'with empty array' do
|
264
|
+
let(:input) { { 'foo' => [] } }
|
265
|
+
|
266
|
+
it 'is successful' do
|
267
|
+
expect(result).to be_successful
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
context 'with filled array' do
|
272
|
+
let(:input) { { 'foo' => [1, 2, 3] } }
|
273
|
+
|
274
|
+
it 'is successful' do
|
275
|
+
expect(result).to be_successful
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
context 'with invalid value' do
|
280
|
+
let(:input) { { 'foo' => 'oops' } }
|
281
|
+
|
282
|
+
it 'is not successful' do
|
283
|
+
expect(result).to be_failing(['must be an array'])
|
284
|
+
end
|
285
|
+
end
|
286
|
+
end
|
243
287
|
end
|
@@ -108,4 +108,19 @@ RSpec.describe Dry::Validation::Schema, 'defining schema using dry types' do
|
|
108
108
|
expect(result.to_h).to eql(quantity: 2, percentage: BigDecimal('0.5'), switch: false)
|
109
109
|
end
|
110
110
|
end
|
111
|
+
|
112
|
+
context 'with each' do
|
113
|
+
subject(:schema) do
|
114
|
+
Dry::Validation.Schema do
|
115
|
+
required(:countries).each(Country)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'applies type constraint checks to each element' do
|
120
|
+
result = schema.(countries: ['Poland', 'Australia'])
|
121
|
+
|
122
|
+
expect(result).to be_success
|
123
|
+
expect(result.to_h).to eql(countries: %w(Poland Australia))
|
124
|
+
end
|
125
|
+
end
|
111
126
|
end
|
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.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-07-
|
12
|
+
date: 2016-07-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: concurrent-ruby
|
@@ -108,7 +108,7 @@ dependencies:
|
|
108
108
|
version: '0.8'
|
109
109
|
- - ">="
|
110
110
|
- !ruby/object:Gem::Version
|
111
|
-
version: 0.8.
|
111
|
+
version: 0.8.1
|
112
112
|
type: :runtime
|
113
113
|
prerelease: false
|
114
114
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -118,7 +118,7 @@ dependencies:
|
|
118
118
|
version: '0.8'
|
119
119
|
- - ">="
|
120
120
|
- !ruby/object:Gem::Version
|
121
|
-
version: 0.8.
|
121
|
+
version: 0.8.1
|
122
122
|
- !ruby/object:Gem::Dependency
|
123
123
|
name: bundler
|
124
124
|
requirement: !ruby/object:Gem::Requirement
|