dry-validation 0.4.0 → 0.4.1
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/dry-validation.gemspec +1 -1
- data/lib/dry/validation/input_type_compiler.rb +5 -1
- data/lib/dry/validation/version.rb +1 -1
- data/spec/unit/input_type_compiler_spec.rb +49 -0
- metadata +7 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e9f6498ea735d03aa4b73fb60bccd3b8a0455c1
|
4
|
+
data.tar.gz: 00230f9f5ecf0af35f05f66c60c2849885a363a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0458a05e52268d2f43656070f72f43c84d2464765f2798b211c79328bc6a1a4fbb70ced00ae5bf5fa4bc9c6e08618c523e476f89061421efd1874fe5f60d1ced
|
7
|
+
data.tar.gz: ac470d5781ee4bff0fa72d5ff35c94c2995baf601814c68059e40c8442c9ad34d171d0ab36970724768e252b0d4225597d85e128bd511ec9edcce5b99be937c2
|
data/CHANGELOG.md
CHANGED
data/dry-validation.gemspec
CHANGED
@@ -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.
|
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],
|
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
|
@@ -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.
|
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-
|
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.
|
68
|
+
version: '0.4'
|
69
69
|
- - ">="
|
70
70
|
- !ruby/object:Gem::Version
|
71
|
-
version: 0.2
|
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.
|
78
|
+
version: '0.4'
|
79
79
|
- - ">="
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version: 0.2
|
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:
|