dry-schema 1.5.1 → 1.5.6
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 +59 -0
- data/README.md +1 -1
- data/dry-schema.gemspec +1 -1
- data/lib/dry/schema/extensions/info/schema_compiler.rb +1 -1
- data/lib/dry/schema/key_validator.rb +2 -2
- data/lib/dry/schema/macros/value.rb +12 -2
- data/lib/dry/schema/message_compiler.rb +19 -2
- data/lib/dry/schema/path.rb +17 -5
- data/lib/dry/schema/result.rb +1 -1
- data/lib/dry/schema/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26cb433ca43bd564e72496a3662035e91cec686962c2c5a3ba9bad0a0c8da5a0
|
4
|
+
data.tar.gz: 8a2decf348bf29e1e2c38e27a0237a872ea78db8b19af32ccdb11adc4928c7dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d6b9d1a6cb3033aadfead9b2dac136cab561c2c0fd2cd97fbd58087168b42ee1cb9e5be34e745c9292d094c6ca2a621aa412b8126b7610d324fdd60f364a373
|
7
|
+
data.tar.gz: 97dc3d3283afbc0c996da01cc2ff566f409dce596a43b5f8158e9f44529e6a0f3427406c9b919bbfb4f9b2884ddb2567dbdb5379e8eb9d4fc49addccee41885c
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,62 @@
|
|
1
|
+
## 1.5.6 2020-10-21
|
2
|
+
|
3
|
+
|
4
|
+
### Fixed
|
5
|
+
|
6
|
+
- Fixed stack error which was a regression introduced in 1.5.5 (issue #322 fixed via #323) (@flash-gordon)
|
7
|
+
|
8
|
+
|
9
|
+
[Compare v1.5.5...v1.5.6](https://github.com/dry-rb/dry-schema/compare/v1.5.5...v1.5.6)
|
10
|
+
|
11
|
+
## 1.5.5 2020-10-08
|
12
|
+
|
13
|
+
|
14
|
+
### Fixed
|
15
|
+
|
16
|
+
- Key validation works with messages that have meta-data (issue #310 fixed via #313) (@tadeusz-niemiec)
|
17
|
+
- Using an external schema along with a key specified as a `:hash` works as expected (issue #296 fixed via #315) (@tadeusz-niemiec + @solnic)
|
18
|
+
- `Result#error?(path)` works correctly when the path points to an array item (issue #317 fixed via #318) (@solnic)
|
19
|
+
|
20
|
+
|
21
|
+
[Compare v1.5.4...v1.5.5](https://github.com/dry-rb/dry-schema/compare/v1.5.4...v1.5.5)
|
22
|
+
|
23
|
+
## 1.5.4
|
24
|
+
|
25
|
+
2020-09-03
|
26
|
+
|
27
|
+
### Fixed
|
28
|
+
|
29
|
+
- Key validation works correctly with a non-nested maybe hashes (issue #311 fixed via #312) (@svobom57)
|
30
|
+
|
31
|
+
|
32
|
+
[Compare v1.5.3...master](https://github.com/dry-rb/dry-schema/compare/v1.5.3...master)
|
33
|
+
|
34
|
+
## 1.5.3 2020-08-21
|
35
|
+
|
36
|
+
|
37
|
+
### Fixed
|
38
|
+
|
39
|
+
- Key validator works correctly with an array with maybe hash as its member (issue #308 fixed via #309) (@tadeusz-niemiec)
|
40
|
+
|
41
|
+
### Changed
|
42
|
+
|
43
|
+
- [info extension] small performance improvement in the set visitor (see #305 for more details) (@esparta)
|
44
|
+
|
45
|
+
[Compare v1.5.2...v1.5.3](https://github.com/dry-rb/dry-schema/compare/v1.5.2...v1.5.3)
|
46
|
+
|
47
|
+
## 1.5.2 2020-06-26
|
48
|
+
|
49
|
+
|
50
|
+
### Fixed
|
51
|
+
|
52
|
+
- `Result#{success?,failure?}` work as expected when there are only key validation failures (issue #297 fixed via #298) (@adamransom)
|
53
|
+
|
54
|
+
### Changed
|
55
|
+
|
56
|
+
- Using `full` option no longer adds a space between the name of a key and the message in case of languages that have no spaces between words (ie Japanese) (issue #161 closed via #292 by @tadeusz-niemiec)
|
57
|
+
|
58
|
+
[Compare v1.5.1...v1.5.2](https://github.com/dry-rb/dry-schema/compare/v1.5.1...v1.5.2)
|
59
|
+
|
1
60
|
## 1.5.1 2020-05-21
|
2
61
|
|
3
62
|
|
data/README.md
CHANGED
data/dry-schema.gemspec
CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.metadata['source_code_uri'] = 'https://github.com/dry-rb/dry-schema'
|
30
30
|
spec.metadata['bug_tracker_uri'] = 'https://github.com/dry-rb/dry-schema/issues'
|
31
31
|
|
32
|
-
spec.required_ruby_version = ">= 2.
|
32
|
+
spec.required_ruby_version = ">= 2.5.0"
|
33
33
|
|
34
34
|
# to update dependencies edit project.yml
|
35
35
|
spec.add_runtime_dependency "concurrent-ruby", "~> 1.0"
|
@@ -28,11 +28,11 @@ module Dry
|
|
28
28
|
if path[INDEX_REGEX]
|
29
29
|
key = path.gsub(INDEX_REGEX, BRACKETS)
|
30
30
|
|
31
|
-
|
31
|
+
if key_paths.none? { |key_path| key_path.include?(key) }
|
32
32
|
arr = path.gsub(INDEX_REGEX) { |m| ".#{m[1]}" }
|
33
33
|
arr.split(DOT).map { |s| DIGIT_REGEX.match?(s) ? s.to_i : s.to_sym }
|
34
34
|
end
|
35
|
-
elsif
|
35
|
+
elsif key_paths.none? { |key_path| key_path.include?(path) }
|
36
36
|
path
|
37
37
|
end
|
38
38
|
|
@@ -28,10 +28,14 @@ module Dry
|
|
28
28
|
|
29
29
|
import_steps(schema)
|
30
30
|
|
31
|
-
|
31
|
+
if !custom_type? || array_type?(current_type) || hash_type?(current_type)
|
32
|
+
type(updated_type)
|
33
|
+
elsif maybe_type?(current_type)
|
34
|
+
type(updated_type.optional)
|
35
|
+
end
|
32
36
|
end
|
33
37
|
|
34
|
-
trace_opts = opts.reject { |key, _|
|
38
|
+
trace_opts = opts.reject { |key, _| %i[type_spec type_rule].include?(key) }
|
35
39
|
|
36
40
|
if (type_rule = opts[:type_rule])
|
37
41
|
trace.append(type_rule).evaluate(*predicates, **trace_opts)
|
@@ -62,10 +66,16 @@ module Dry
|
|
62
66
|
primitive_inferrer[type].eql?([::Array])
|
63
67
|
end
|
64
68
|
|
69
|
+
# @api private
|
65
70
|
def hash_type?(type)
|
66
71
|
primitive_inferrer[type].eql?([::Hash])
|
67
72
|
end
|
68
73
|
|
74
|
+
# @api private
|
75
|
+
def maybe_type?(type)
|
76
|
+
type.meta[:maybe].equal?(true)
|
77
|
+
end
|
78
|
+
|
69
79
|
# @api private
|
70
80
|
def build_array_type(array_type, member)
|
71
81
|
if array_type.respond_to?(:of)
|
@@ -29,6 +29,14 @@ module Dry
|
|
29
29
|
|
30
30
|
EMPTY_OPTS = VisitorOpts.new
|
31
31
|
EMPTY_MESSAGE_SET = MessageSet.new(EMPTY_ARRAY).freeze
|
32
|
+
FULL_MESSAGE_WHITESPACE = Hash.new(' ').merge(
|
33
|
+
ja: '',
|
34
|
+
zh: '',
|
35
|
+
bn: '',
|
36
|
+
th: '',
|
37
|
+
lo: '',
|
38
|
+
my: '',
|
39
|
+
)
|
32
40
|
|
33
41
|
param :messages
|
34
42
|
|
@@ -108,6 +116,7 @@ module Dry
|
|
108
116
|
|
109
117
|
Message.new(
|
110
118
|
path: path,
|
119
|
+
meta: msg[:meta] || EMPTY_HASH,
|
111
120
|
text: msg[:text],
|
112
121
|
predicate: nil,
|
113
122
|
input: input
|
@@ -203,12 +212,12 @@ module Dry
|
|
203
212
|
return text if !text || !full
|
204
213
|
|
205
214
|
rule = options[:path]
|
206
|
-
|
215
|
+
[messages.rule(rule, options) || rule, text].join(FULL_MESSAGE_WHITESPACE[template.options[:locale]])
|
207
216
|
end
|
208
217
|
|
209
218
|
# @api private
|
210
219
|
def message_tokens(args)
|
211
|
-
args.each_with_object({}) do |arg, hash|
|
220
|
+
tokens = args.each_with_object({}) do |arg, hash|
|
212
221
|
case arg[1]
|
213
222
|
when Array
|
214
223
|
hash[arg[0]] = arg[1].join(LIST_SEPARATOR)
|
@@ -219,6 +228,14 @@ module Dry
|
|
219
228
|
hash[arg[0]] = arg[1]
|
220
229
|
end
|
221
230
|
end
|
231
|
+
args.any? { |e| e.first == :size } ? append_mapped_size_tokens(tokens) : tokens
|
232
|
+
end
|
233
|
+
|
234
|
+
# @api private
|
235
|
+
def append_mapped_size_tokens(tokens)
|
236
|
+
# this is a temporary fix for the inconsistency in the "size" errors arguments
|
237
|
+
mapped_hash = tokens.each_with_object({}) { |(k, v), h| h[k.to_s.gsub("size", "num").to_sym] = v }
|
238
|
+
tokens.merge(mapped_hash)
|
222
239
|
end
|
223
240
|
end
|
224
241
|
end
|
data/lib/dry/schema/path.rb
CHANGED
@@ -90,13 +90,25 @@ module Dry
|
|
90
90
|
keys.index(key)
|
91
91
|
end
|
92
92
|
|
93
|
+
def without_index
|
94
|
+
self.class.new(to_a[0..-2])
|
95
|
+
end
|
96
|
+
|
93
97
|
# @api private
|
94
98
|
def include?(other)
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
99
|
+
if !same_root?(other)
|
100
|
+
false
|
101
|
+
elsif index?
|
102
|
+
if other.index?
|
103
|
+
last.equal?(other.last)
|
104
|
+
else
|
105
|
+
without_index.include?(other)
|
106
|
+
end
|
107
|
+
elsif other.index? && key_matches(other, :select).size < 2
|
108
|
+
false
|
109
|
+
else
|
110
|
+
self >= other && !other.key_matches(self).include?(nil)
|
111
|
+
end
|
100
112
|
end
|
101
113
|
|
102
114
|
# @api private
|
data/lib/dry/schema/result.rb
CHANGED
data/lib/dry/schema/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-schema
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Solnica
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -253,7 +253,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
253
253
|
requirements:
|
254
254
|
- - ">="
|
255
255
|
- !ruby/object:Gem::Version
|
256
|
-
version: 2.
|
256
|
+
version: 2.5.0
|
257
257
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
258
258
|
requirements:
|
259
259
|
- - ">="
|