dry-schema 1.5.2 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +76 -0
- data/LICENSE +1 -1
- data/README.md +1 -1
- data/dry-schema.gemspec +3 -4
- data/lib/dry/schema/config.rb +1 -1
- data/lib/dry/schema/extensions/info/schema_compiler.rb +1 -1
- data/lib/dry/schema/key_coercer.rb +1 -1
- data/lib/dry/schema/key_map.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.rb +1 -1
- data/lib/dry/schema/message/or/multi_path.rb +1 -1
- data/lib/dry/schema/message/or/single_path.rb +1 -1
- data/lib/dry/schema/message_compiler.rb +5 -1
- data/lib/dry/schema/message_set.rb +1 -1
- data/lib/dry/schema/messages/abstract.rb +1 -1
- data/lib/dry/schema/messages/template.rb +1 -1
- data/lib/dry/schema/messages/yaml.rb +1 -1
- data/lib/dry/schema/path.rb +17 -5
- data/lib/dry/schema/predicate.rb +1 -1
- data/lib/dry/schema/result.rb +1 -1
- data/lib/dry/schema/value_coercer.rb +1 -1
- data/lib/dry/schema/version.rb +1 -1
- metadata +13 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 286fc26d17ad546acf8370b4fdba754c85f495a0d6dd8da0c4ce564066c30859
|
4
|
+
data.tar.gz: b6f080291da562eca2e1e4407e9fc079062b45a12c7d24739137b5e7502be429
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 340ac4d40469019131a1bc3ff0284b95ee7d83b151b013cc91ded5eb1629cc35ab535ac7e3c8a3dc70033e955ec91629df8ed18b89b44f9cacb50c4c1231f283
|
7
|
+
data.tar.gz: 4847c4e9ee2d9fa28051d6ec0a160415505e3f7475c95ef550cca927ed9b59f78da4be4333064a9e750a395cb497e09d36f9e70e44333e46850506f6365ba82e
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,79 @@
|
|
1
|
+
<!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
|
2
|
+
|
3
|
+
## 1.6.0 2021-01-21
|
4
|
+
|
5
|
+
|
6
|
+
### Fixed
|
7
|
+
|
8
|
+
- Using sum types with a i18n backend no longer crashes (issue #328 fixes via #331) (@tylerhunt)
|
9
|
+
|
10
|
+
### Changed
|
11
|
+
|
12
|
+
- Inferring predicates from class names is deprecated. It's very unlikely your code depends on it,
|
13
|
+
however, if it does, you'll get an exception with instructions. (@flash-gordon)
|
14
|
+
|
15
|
+
If you see an exception and don't rely on inferring, just disable it with:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
Dry::Schema::PredicateInferrer::Compiler.infer_predicate_by_class_name false
|
19
|
+
```
|
20
|
+
|
21
|
+
Otherwise, enable it explicitly:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
Dry::Schema::PredicateInferrer::Compiler.infer_predicate_by_class_name true
|
25
|
+
```
|
26
|
+
|
27
|
+
See https://github.com/dry-rb/dry-schema/issues/335 for rationale.
|
28
|
+
|
29
|
+
[Compare v1.5.6...v1.6.0](https://github.com/dry-rb/dry-schema/compare/v1.5.6...v1.6.0)
|
30
|
+
|
31
|
+
## 1.5.6 2020-10-21
|
32
|
+
|
33
|
+
|
34
|
+
### Fixed
|
35
|
+
|
36
|
+
- Fixed stack error which was a regression introduced in 1.5.5 (issue #322 fixed via #323) (@flash-gordon)
|
37
|
+
|
38
|
+
|
39
|
+
[Compare v1.5.5...v1.5.6](https://github.com/dry-rb/dry-schema/compare/v1.5.5...v1.5.6)
|
40
|
+
|
41
|
+
## 1.5.5 2020-10-08
|
42
|
+
|
43
|
+
|
44
|
+
### Fixed
|
45
|
+
|
46
|
+
- Key validation works with messages that have meta-data (issue #310 fixed via #313) (@tadeusz-niemiec)
|
47
|
+
- Using an external schema along with a key specified as a `:hash` works as expected (issue #296 fixed via #315) (@tadeusz-niemiec + @solnic)
|
48
|
+
- `Result#error?(path)` works correctly when the path points to an array item (issue #317 fixed via #318) (@solnic)
|
49
|
+
|
50
|
+
|
51
|
+
[Compare v1.5.4...v1.5.5](https://github.com/dry-rb/dry-schema/compare/v1.5.4...v1.5.5)
|
52
|
+
|
53
|
+
## 1.5.4
|
54
|
+
|
55
|
+
2020-09-03
|
56
|
+
|
57
|
+
### Fixed
|
58
|
+
|
59
|
+
- Key validation works correctly with a non-nested maybe hashes (issue #311 fixed via #312) (@svobom57)
|
60
|
+
|
61
|
+
|
62
|
+
[Compare v1.5.3...master](https://github.com/dry-rb/dry-schema/compare/v1.5.3...master)
|
63
|
+
|
64
|
+
## 1.5.3 2020-08-21
|
65
|
+
|
66
|
+
|
67
|
+
### Fixed
|
68
|
+
|
69
|
+
- Key validator works correctly with an array with maybe hash as its member (issue #308 fixed via #309) (@tadeusz-niemiec)
|
70
|
+
|
71
|
+
### Changed
|
72
|
+
|
73
|
+
- [info extension] small performance improvement in the set visitor (see #305 for more details) (@esparta)
|
74
|
+
|
75
|
+
[Compare v1.5.2...v1.5.3](https://github.com/dry-rb/dry-schema/compare/v1.5.2...v1.5.3)
|
76
|
+
|
1
77
|
## 1.5.2 2020-06-26
|
2
78
|
|
3
79
|
|
data/LICENSE
CHANGED
data/README.md
CHANGED
data/dry-schema.gemspec
CHANGED
@@ -29,16 +29,15 @@ 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"
|
36
36
|
spec.add_runtime_dependency "dry-configurable", "~> 0.8", ">= 0.8.3"
|
37
|
-
spec.add_runtime_dependency "dry-core", "~> 0.
|
38
|
-
spec.add_runtime_dependency "dry-equalizer", "~> 0.2"
|
37
|
+
spec.add_runtime_dependency "dry-core", "~> 0.5", ">= 0.5"
|
39
38
|
spec.add_runtime_dependency "dry-initializer", "~> 3.0"
|
40
39
|
spec.add_runtime_dependency "dry-logic", "~> 1.0"
|
41
|
-
spec.add_runtime_dependency "dry-types", "~> 1.
|
40
|
+
spec.add_runtime_dependency "dry-types", "~> 1.5"
|
42
41
|
|
43
42
|
spec.add_development_dependency "bundler"
|
44
43
|
spec.add_development_dependency "rake"
|
data/lib/dry/schema/config.rb
CHANGED
data/lib/dry/schema/key_map.rb
CHANGED
@@ -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)
|
data/lib/dry/schema/message.rb
CHANGED
@@ -116,6 +116,7 @@ module Dry
|
|
116
116
|
|
117
117
|
Message.new(
|
118
118
|
path: path,
|
119
|
+
meta: msg[:meta] || EMPTY_HASH,
|
119
120
|
text: msg[:text],
|
120
121
|
predicate: nil,
|
121
122
|
input: input
|
@@ -130,7 +131,10 @@ module Dry
|
|
130
131
|
|
131
132
|
# @api private
|
132
133
|
def or_translator
|
133
|
-
@or_translator ||= proc { |k|
|
134
|
+
@or_translator ||= proc { |k|
|
135
|
+
message = messages.translate(k, **default_lookup_options)
|
136
|
+
message.is_a?(Hash) ? message[:text] : message
|
137
|
+
}
|
134
138
|
end
|
135
139
|
|
136
140
|
# @api private
|
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/predicate.rb
CHANGED
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.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Solnica
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -50,28 +50,20 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '0.
|
54
|
-
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
requirements:
|
58
|
-
- - "~>"
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: '0.4'
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
|
-
name: dry-equalizer
|
63
|
-
requirement: !ruby/object:Gem::Requirement
|
64
|
-
requirements:
|
65
|
-
- - "~>"
|
53
|
+
version: '0.5'
|
54
|
+
- - ">="
|
66
55
|
- !ruby/object:Gem::Version
|
67
|
-
version: '0.
|
56
|
+
version: '0.5'
|
68
57
|
type: :runtime
|
69
58
|
prerelease: false
|
70
59
|
version_requirements: !ruby/object:Gem::Requirement
|
71
60
|
requirements:
|
72
61
|
- - "~>"
|
73
62
|
- !ruby/object:Gem::Version
|
74
|
-
version: '0.
|
63
|
+
version: '0.5'
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0.5'
|
75
67
|
- !ruby/object:Gem::Dependency
|
76
68
|
name: dry-initializer
|
77
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -106,14 +98,14 @@ dependencies:
|
|
106
98
|
requirements:
|
107
99
|
- - "~>"
|
108
100
|
- !ruby/object:Gem::Version
|
109
|
-
version: '1.
|
101
|
+
version: '1.5'
|
110
102
|
type: :runtime
|
111
103
|
prerelease: false
|
112
104
|
version_requirements: !ruby/object:Gem::Requirement
|
113
105
|
requirements:
|
114
106
|
- - "~>"
|
115
107
|
- !ruby/object:Gem::Version
|
116
|
-
version: '1.
|
108
|
+
version: '1.5'
|
117
109
|
- !ruby/object:Gem::Dependency
|
118
110
|
name: bundler
|
119
111
|
requirement: !ruby/object:Gem::Requirement
|
@@ -253,14 +245,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
253
245
|
requirements:
|
254
246
|
- - ">="
|
255
247
|
- !ruby/object:Gem::Version
|
256
|
-
version: 2.
|
248
|
+
version: 2.5.0
|
257
249
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
258
250
|
requirements:
|
259
251
|
- - ">="
|
260
252
|
- !ruby/object:Gem::Version
|
261
253
|
version: '0'
|
262
254
|
requirements: []
|
263
|
-
rubygems_version: 3.
|
255
|
+
rubygems_version: 3.1.4
|
264
256
|
signing_key:
|
265
257
|
specification_version: 4
|
266
258
|
summary: Coercion and validation for data structures
|