dry-schema 1.4.2 → 1.4.3
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 +28 -0
- data/LICENSE +1 -1
- data/README.md +4 -4
- data/lib/dry/schema/config.rb +1 -1
- data/lib/dry/schema/macros/maybe.rb +1 -2
- data/lib/dry/schema/macros/value.rb +7 -2
- data/lib/dry/schema/message_compiler.rb +1 -1
- data/lib/dry/schema/message_set.rb +2 -2
- data/lib/dry/schema/messages/i18n.rb +3 -3
- data/lib/dry/schema/messages/yaml.rb +1 -1
- data/lib/dry/schema/result.rb +9 -0
- 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: e079ef300d87844185052fe2a2c3e42230d29aefd409ec0acf6b9a45d3f296f5
|
4
|
+
data.tar.gz: cf34b9651357525e874109f4533e8c23c2f682ca33ffe90da0e789037491cfe2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bb4f328f94be77fcdeb4791c5227d694a93522880dbc7ed48684033e83f37ce62da9627820d2ba53606f231ac6e5add562a1d2cd502a851b8bab8415e748882
|
7
|
+
data.tar.gz: 1866a985a5bc45eb84c8670c8b67b209fd3397f656a82080debcc7cfa8a29284e7de6528a1b662eeafd61f0bbe2094328401ede95f381be7c765322de782690d
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,31 @@
|
|
1
|
+
# 1.4.3 2020-01-08
|
2
|
+
|
3
|
+
### Added
|
4
|
+
|
5
|
+
* Pattern matching for `Dry::Schema::Result` objects (@flash-gordon)
|
6
|
+
```ruby
|
7
|
+
schema = Dry::Schema::Params { required(:name).filled }
|
8
|
+
case schema.('name' => 'John')
|
9
|
+
in name:
|
10
|
+
name # => 'John'
|
11
|
+
end
|
12
|
+
```
|
13
|
+
Try it with monads!
|
14
|
+
* Shortcut for nested schemas in `value` and `maybe` macros (@waiting-for-dev)
|
15
|
+
```ruby
|
16
|
+
Dry::Schema.Params do
|
17
|
+
required(:address).value(:hash) do
|
18
|
+
required(:city).filled
|
19
|
+
end
|
20
|
+
end
|
21
|
+
```
|
22
|
+
|
23
|
+
### Fixed
|
24
|
+
|
25
|
+
* Some keyword warnings that slipped into the previous release (@flash-gordon)
|
26
|
+
|
27
|
+
[Compare v1.4.2...v1.4.3](https://github.com/dry-rb/dry-schema/compare/v1.4.2...v1.4.3)
|
28
|
+
|
1
29
|
# 1.4.2 2019-12-19
|
2
30
|
|
3
31
|
### Fixed
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
[gem]: https://rubygems.org/gems/dry-schema
|
2
2
|
[actions]: https://github.com/dry-rb/dry-schema/actions
|
3
|
-
[
|
3
|
+
[codacy]: https://www.codacy.com/gh/dry-rb/dry-schema
|
4
4
|
[chat]: https://dry-rb.zulipchat.com
|
5
5
|
[inchpages]: http://inch-ci.org/github/dry-rb/dry-schema
|
6
6
|
|
@@ -8,8 +8,8 @@
|
|
8
8
|
|
9
9
|
[][gem]
|
10
10
|
[][actions]
|
11
|
-
[][codacy]
|
12
|
+
[][codacy]
|
13
13
|
[][inchpages]
|
14
14
|
|
15
15
|
## Links
|
@@ -19,7 +19,7 @@
|
|
19
19
|
|
20
20
|
## Supported Ruby versions
|
21
21
|
|
22
|
-
This library officially supports following Ruby versions:
|
22
|
+
This library officially supports the following Ruby versions:
|
23
23
|
|
24
24
|
* MRI >= `2.4`
|
25
25
|
* jruby >= `9.2`
|
data/lib/dry/schema/config.rb
CHANGED
@@ -27,13 +27,18 @@ module Dry
|
|
27
27
|
end
|
28
28
|
|
29
29
|
trace.evaluate(*predicates, **opts)
|
30
|
-
|
30
|
+
|
31
|
+
type_spec = opts[:type_spec]
|
32
|
+
if block && type_spec.equal?(:hash)
|
33
|
+
hash(&block)
|
34
|
+
elsif block
|
35
|
+
trace.append(new(chain: false).instance_exec(&block))
|
36
|
+
end
|
31
37
|
|
32
38
|
if trace.captures.empty?
|
33
39
|
raise ArgumentError, 'wrong number of arguments (given 0, expected at least 1)'
|
34
40
|
end
|
35
41
|
|
36
|
-
type_spec = opts[:type_spec]
|
37
42
|
each(type_spec.type.member) if type_spec.respond_to?(:member)
|
38
43
|
|
39
44
|
self
|
@@ -131,7 +131,7 @@ module Dry
|
|
131
131
|
).to_h
|
132
132
|
|
133
133
|
template, meta = messages[predicate, options] ||
|
134
|
-
|
134
|
+
raise(MissingMessageError.new(path, messages.looked_up_paths(predicate, options)))
|
135
135
|
|
136
136
|
text = message_text(template, tokens, options)
|
137
137
|
|
@@ -17,13 +17,13 @@ module Dry
|
|
17
17
|
#
|
18
18
|
# @return [Array<Message>]
|
19
19
|
attr_reader :messages
|
20
|
-
|
20
|
+
|
21
21
|
# An internal hash that is filled in with dumped messages
|
22
22
|
# when a message set is coerced to a hash
|
23
23
|
#
|
24
24
|
# @return [Hash<Symbol=>[Array,Hash]>]
|
25
25
|
attr_reader :placeholders
|
26
|
-
|
26
|
+
|
27
27
|
# Options hash
|
28
28
|
#
|
29
29
|
# @return [Hash]
|
@@ -33,7 +33,7 @@ module Dry
|
|
33
33
|
|
34
34
|
opts = { locale: options.fetch(:locale, default_locale) }
|
35
35
|
|
36
|
-
translation = t.(key, opts)
|
36
|
+
translation = t.(key, **opts)
|
37
37
|
text_key = "#{key}.text"
|
38
38
|
|
39
39
|
if !translation.is_a?(Hash) || !key?(text_key, opts)
|
@@ -44,7 +44,7 @@ module Dry
|
|
44
44
|
end
|
45
45
|
|
46
46
|
{
|
47
|
-
text: t.(text_key, opts),
|
47
|
+
text: t.(text_key, **opts),
|
48
48
|
meta: extract_meta(key, translation, opts)
|
49
49
|
}
|
50
50
|
end
|
@@ -121,7 +121,7 @@ module Dry
|
|
121
121
|
def extract_meta(parent_key, translation, options)
|
122
122
|
translation.keys.each_with_object({}) do |k, meta|
|
123
123
|
meta_key = "#{parent_key}.#{k}"
|
124
|
-
meta[k] = t.(meta_key, options) if k != :text && key?(meta_key, options)
|
124
|
+
meta[k] = t.(meta_key, **options) if k != :text && key?(meta_key, options)
|
125
125
|
end
|
126
126
|
end
|
127
127
|
end
|
data/lib/dry/schema/result.rb
CHANGED
@@ -136,6 +136,15 @@ module Dry
|
|
136
136
|
"#<#{self.class}#{to_h.inspect} errors=#{errors.to_h.inspect}>"
|
137
137
|
end
|
138
138
|
|
139
|
+
if RUBY_VERSION >= '2.7'
|
140
|
+
# Pattern matching support
|
141
|
+
#
|
142
|
+
# @api private
|
143
|
+
def deconstruct_keys(_)
|
144
|
+
output
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
139
148
|
private
|
140
149
|
|
141
150
|
# A list of failure ASTs produced by rule result objects
|
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.
|
4
|
+
version: 1.4.3
|
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: 2020-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -246,7 +246,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
246
246
|
- !ruby/object:Gem::Version
|
247
247
|
version: '0'
|
248
248
|
requirements: []
|
249
|
-
rubygems_version: 3.
|
249
|
+
rubygems_version: 3.1.2
|
250
250
|
signing_key:
|
251
251
|
specification_version: 4
|
252
252
|
summary: Coercion and validation for data structures
|