dry-validation 0.10.2 → 0.10.3

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: 4812f30b70d5f756baf7da235b8e37e75590bdd8
4
- data.tar.gz: c7685c3581fbcbb70f67908db92a41913ec2e411
3
+ metadata.gz: ad0f90e5090baa3afaf8d120f05f35f1429f3854
4
+ data.tar.gz: 6c36b63d3975d7a60daed91545fac2e06547a808
5
5
  SHA512:
6
- metadata.gz: b7d4c1f2cf92afada3081bf943098faa1bfa7e3cd86f8389b0ea184a47522ec5ee6bacd3b51a43b61fe4ec7cb0c030218e24bd755206eb3bfcf7afa30c5abd0e
7
- data.tar.gz: 8e350c18d4d577c4b5e4c9106822d872c8c3a3a2e35f43a1f9a0d283e24a750edc41313f1385c1f1463232239a59960d0746943c71a260b63aeba35a5bde9202
6
+ metadata.gz: 76f9702473cf3f94f5254c965b29de19df3c050a05fe35c3c4b0e04efc0b67ed71604b698a6de8dd47bf76c12390637ab02931f9f706264f3fbdbf99c3199c58
7
+ data.tar.gz: 56f8d8da5d7ab1aadf7b46f4b445c6a4f19a83a5e6f49ceedab84481aa9d503781713d59d6a8075932f763dab424df040767fb6db750f5ca04393160f630c3d3
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # v0.10.3 2016-09-27
2
+
3
+ ### Fixed
4
+
5
+ * Custom predicates work correctly with `each` macro (solnic)
6
+
7
+ [Compare v0.10.2...v0.10.3](https://github.com/dryrb/dry-validation/compare/v0.10.2...v0.10.3)
8
+
1
9
  # v0.10.2 2016-09-23
2
10
 
3
11
  ### Fixed
@@ -165,7 +165,7 @@ module Dry
165
165
  end
166
166
 
167
167
  def dyn_arg?(name)
168
- schema_class.instance_methods.include?(name)
168
+ !name.to_s.end_with?('?') && schema_class.instance_methods.include?(name)
169
169
  end
170
170
 
171
171
  def respond_to?(name)
@@ -1,5 +1,5 @@
1
1
  module Dry
2
2
  module Validation
3
- VERSION = '0.10.2'.freeze
3
+ VERSION = '0.10.3'.freeze
4
4
  end
5
5
  end
@@ -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.2
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-23 00:00:00.000000000 Z
12
+ date: 2016-09-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: concurrent-ruby