dry-validation 0.10.2 → 0.10.3
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/schema/value.rb +1 -1
- data/lib/dry/validation/version.rb +1 -1
- data/spec/integration/schema/macros/each_spec.rb +28 -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: ad0f90e5090baa3afaf8d120f05f35f1429f3854
|
4
|
+
data.tar.gz: 6c36b63d3975d7a60daed91545fac2e06547a808
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76f9702473cf3f94f5254c965b29de19df3c050a05fe35c3c4b0e04efc0b67ed71604b698a6de8dd47bf76c12390637ab02931f9f706264f3fbdbf99c3199c58
|
7
|
+
data.tar.gz: 56f8d8da5d7ab1aadf7b46f4b445c6a4f19a83a5e6f49ceedab84481aa9d503781713d59d6a8075932f763dab424df040767fb6db750f5ca04393160f630c3d3
|
data/CHANGELOG.md
CHANGED
@@ -237,4 +237,32 @@ RSpec.describe 'Macros #each' do
|
|
237
237
|
end
|
238
238
|
end
|
239
239
|
end
|
240
|
+
|
241
|
+
context 'with a custom predicate' do
|
242
|
+
subject(:schema) do
|
243
|
+
Dry::Validation.Schema do
|
244
|
+
configure do
|
245
|
+
def self.messages
|
246
|
+
super.merge(en: { errors: { valid_content?: 'must have type key' }})
|
247
|
+
end
|
248
|
+
|
249
|
+
def valid_content?(content)
|
250
|
+
content.key?(:type)
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
required(:contents).each(:valid_content?)
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
it 'passes when all elements are valid' do
|
259
|
+
expect(schema.(contents: [{ type: 'foo' }, { type: 'bar' }]))
|
260
|
+
end
|
261
|
+
|
262
|
+
it 'fails when some elements are not valid' do
|
263
|
+
expect(schema.(contents: [{ type: 'foo' }, { oops: 'bar' }]).errors).to eql(
|
264
|
+
contents: { 1 => ['must have type key']}
|
265
|
+
)
|
266
|
+
end
|
267
|
+
end
|
240
268
|
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.10.
|
4
|
+
version: 0.10.3
|
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-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: concurrent-ruby
|