dry-schema 1.5.4 → 1.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/lib/dry/schema/macros/value.rb +12 -2
- data/lib/dry/schema/message_compiler.rb +1 -0
- data/lib/dry/schema/path.rb +16 -1
- data/lib/dry/schema/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 442f6c2c04925f14ec6f0230394ad8e009518e9a2d7c1db22ddf68416324d530
|
4
|
+
data.tar.gz: 8f210323df91ba5ebf8a947b5888907b6f6f7cac504f93fbec80af8678dbdeb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87c2dcc7e169f2ff4c474038a0821a77e9f71420d40d2a4fe59f1d0ab722bcbbc3b9a60dcb33107d34d77cd303a82c33ebb3d084c350a49fc13e7b4cd73666f8
|
7
|
+
data.tar.gz: 59442e66361d9a1daf9de31480681bf0414875f22b9cdd440224db7b1a5fde818bdc479e2296cea558b00e9b698df56645aa65a55da59bb2bde2d67b4b979120
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
## 1.5.5 2020-10-08
|
2
|
+
|
3
|
+
|
4
|
+
### Fixed
|
5
|
+
|
6
|
+
- Key validation works with messages that have meta-data (issue #310 fixed via #313) (@tadeusz-niemiec)
|
7
|
+
- Using an external schema along with a key specified as a `:hash` works as expected (issue #296 fixed via #315) (@tadeusz-niemiec + @solnic)
|
8
|
+
- `Result#error?(path)` works correctly when the path points to an array item (issue #317 fixed via #318) (@solnic)
|
9
|
+
|
10
|
+
|
11
|
+
[Compare v1.5.4...v1.5.5](https://github.com/dry-rb/dry-schema/compare/v1.5.4...v1.5.5)
|
12
|
+
|
1
13
|
## 1.5.4
|
2
14
|
|
3
15
|
2020-09-03
|
@@ -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/path.rb
CHANGED
@@ -90,14 +90,29 @@ 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
|
98
|
+
#
|
99
|
+
# rubocop:disable Metrics/PerceivedComplexity
|
94
100
|
def include?(other)
|
95
101
|
return false unless same_root?(other)
|
96
102
|
return last.equal?(other.last) if index? && other.index?
|
97
|
-
return
|
103
|
+
return without_index.include?(other) if index?
|
104
|
+
|
105
|
+
if !index? && other.index?
|
106
|
+
path = key_matches(other, :select)
|
107
|
+
|
108
|
+
return false unless path.size > 1
|
109
|
+
|
110
|
+
self.class.new(path).include?(other)
|
111
|
+
end
|
98
112
|
|
99
113
|
self >= other && !other.key_matches(self).include?(nil)
|
100
114
|
end
|
115
|
+
# rubocop:enable Metrics/PerceivedComplexity
|
101
116
|
|
102
117
|
# @api private
|
103
118
|
def <=>(other)
|
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.5
|
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-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|