dry-validation 0.4.0 → 0.4.1

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: 8bb5ae409a8e2f6c8aca26fd536cd36acf079d47
4
- data.tar.gz: e75a4be1f0dc512db4b4e60b8b3651ee9b1ab480
3
+ metadata.gz: 7e9f6498ea735d03aa4b73fb60bccd3b8a0455c1
4
+ data.tar.gz: 00230f9f5ecf0af35f05f66c60c2849885a363a1
5
5
  SHA512:
6
- metadata.gz: 6c186c20423a18a808289dc9823f80e77d5b10239d42918bdbde1c2b2ebb0cd70591f6450edf96a9b7adc526fc98c722ceb553b59fca5d5eba602977015d8459
7
- data.tar.gz: 30d0e0faaebcdd2fa25ea687f6e07023a8eb9a39094a6feb32a36c6e52d69ff28dbe6bb3d48be2f0077f0d1df9b8df8379e544e3937f84b2a5c78bc8fc755c85
6
+ metadata.gz: 0458a05e52268d2f43656070f72f43c84d2464765f2798b211c79328bc6a1a4fbb70ced00ae5bf5fa4bc9c6e08618c523e476f89061421efd1874fe5f60d1ced
7
+ data.tar.gz: ac470d5781ee4bff0fa72d5ff35c94c2995baf601814c68059e40c8442c9ad34d171d0ab36970724768e252b0d4225597d85e128bd511ec9edcce5b99be937c2
@@ -1,3 +1,11 @@
1
+ # v0.4.1 2015-12-27
2
+
3
+ ### Added
4
+
5
+ * Support for `each` and type coercion inference in `Schema::Form` (solnic)
6
+
7
+ [Compare v0.4.0...v0.4.1](https://github.com/dryrb/dry-validation/compare/v0.4.0...v0.4.1)
8
+
1
9
  # v0.4.0 2015-12-21
2
10
 
3
11
  ### Added
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.add_runtime_dependency 'dry-configurable', '~> 0.1'
19
19
  spec.add_runtime_dependency 'dry-container', '~> 0.2', '>= 0.2.6'
20
20
  spec.add_runtime_dependency 'dry-equalizer', '~> 0.2'
21
- spec.add_runtime_dependency 'dry-data', '~> 0.2', '>= 0.2.1'
21
+ spec.add_runtime_dependency 'dry-data', '~> 0.4', '>= 0.4.2'
22
22
 
23
23
  spec.add_development_dependency 'bundler'
24
24
  spec.add_development_dependency 'rake'
@@ -64,13 +64,17 @@ module Dry
64
64
  end
65
65
 
66
66
  def visit_val(node, *args)
67
- visit(node[1], *args)
67
+ visit(node[1], false)
68
68
  end
69
69
 
70
70
  def visit_set(node, *args)
71
71
  [:type, ['hash', [:symbolized, node[1].map { |n| visit(n) }]]]
72
72
  end
73
73
 
74
+ def visit_each(node, *args)
75
+ [:type, ['array', visit(node[1], *args)]]
76
+ end
77
+
74
78
  def visit_predicate(node, *args)
75
79
  [:type, TYPES[node[0]] || TYPES[:default]]
76
80
  end
@@ -1,5 +1,5 @@
1
1
  module Dry
2
2
  module Validation
3
- VERSION = '0.4.0'.freeze
3
+ VERSION = '0.4.1'.freeze
4
4
  end
5
5
  end
@@ -186,6 +186,7 @@ RSpec.describe Dry::Validation::InputTypeCompiler, '#call' do
186
186
 
187
187
  expect(input_type['bday' => '2012-01-23 11:07']).to eql(bday: Time.new(2012, 1, 23, 11, 7))
188
188
  end
189
+
189
190
  it 'supports time? => "form.time"' do
190
191
  rule_ast = [
191
192
  [
@@ -202,4 +203,52 @@ RSpec.describe Dry::Validation::InputTypeCompiler, '#call' do
202
203
  expect(input_type['admin' => 'true']).to eql(admin: true)
203
204
  expect(input_type['admin' => 'false']).to eql(admin: false)
204
205
  end
206
+
207
+ it 'supports each rule' do
208
+ rule_ast = [
209
+ [
210
+ :and, [
211
+ [:key, [:author, [:predicate, [:key?, []]]]],
212
+ [
213
+ :set, [
214
+ :author, [
215
+ [
216
+ :and, [
217
+ [:key, [:books, [:predicate, [:key?, []]]]],
218
+ [
219
+ :each, [
220
+ :books,
221
+ [
222
+ :set, [
223
+ :books, [
224
+ [
225
+ :and, [
226
+ [:key, [:published, [:predicate, [:key?, []]]]],
227
+ [:val, [:published, [:predicate, [:bool?, []]]]]
228
+ ]
229
+ ]
230
+ ]
231
+ ]
232
+ ]
233
+ ]
234
+ ]
235
+ ]
236
+ ]
237
+ ]
238
+ ]
239
+ ]
240
+ ]
241
+ ]
242
+ ]
243
+
244
+ input_type = compiler.(rule_ast)
245
+
246
+ expect(input_type['author' => { 'books' => [{ 'published' => 'true' }] }]).to eql(
247
+ author: { books: [published: true] }
248
+ )
249
+
250
+ expect(input_type['author' => { 'books' => [{ 'published' => 'false' }] }]).to eql(
251
+ author: { books: [published: false] }
252
+ )
253
+ end
205
254
  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.4.0
4
+ version: 0.4.1
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: 2015-12-21 00:00:00.000000000 Z
12
+ date: 2015-12-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: dry-configurable
@@ -65,20 +65,20 @@ dependencies:
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0.2'
68
+ version: '0.4'
69
69
  - - ">="
70
70
  - !ruby/object:Gem::Version
71
- version: 0.2.1
71
+ version: 0.4.2
72
72
  type: :runtime
73
73
  prerelease: false
74
74
  version_requirements: !ruby/object:Gem::Requirement
75
75
  requirements:
76
76
  - - "~>"
77
77
  - !ruby/object:Gem::Version
78
- version: '0.2'
78
+ version: '0.4'
79
79
  - - ">="
80
80
  - !ruby/object:Gem::Version
81
- version: 0.2.1
81
+ version: 0.4.2
82
82
  - !ruby/object:Gem::Dependency
83
83
  name: bundler
84
84
  requirement: !ruby/object:Gem::Requirement
@@ -259,7 +259,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
259
259
  version: '0'
260
260
  requirements: []
261
261
  rubyforge_project:
262
- rubygems_version: 2.4.5
262
+ rubygems_version: 2.4.5.1
263
263
  signing_key:
264
264
  specification_version: 4
265
265
  summary: A simple validation library
@@ -323,4 +323,3 @@ test_files:
323
323
  - spec/unit/schema/rule_spec.rb
324
324
  - spec/unit/schema/value_spec.rb
325
325
  - spec/unit/schema_spec.rb
326
- has_rdoc: