dry-schema 1.7.0 → 1.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +43 -0
  3. data/README.md +2 -2
  4. data/dry-schema.gemspec +2 -2
  5. data/lib/dry/schema/compiler.rb +1 -1
  6. data/lib/dry/schema/config.rb +9 -9
  7. data/lib/dry/schema/dsl.rb +7 -4
  8. data/lib/dry/schema/extensions/hints/message_compiler_methods.rb +9 -4
  9. data/lib/dry/schema/extensions/hints.rb +11 -9
  10. data/lib/dry/schema/extensions/info/schema_compiler.rb +10 -1
  11. data/lib/dry/schema/extensions/json_schema/schema_compiler.rb +232 -0
  12. data/lib/dry/schema/extensions/json_schema.rb +29 -0
  13. data/lib/dry/schema/extensions/struct.rb +1 -1
  14. data/lib/dry/schema/extensions.rb +4 -0
  15. data/lib/dry/schema/key.rb +75 -74
  16. data/lib/dry/schema/key_coercer.rb +2 -2
  17. data/lib/dry/schema/key_validator.rb +44 -23
  18. data/lib/dry/schema/macros/array.rb +4 -0
  19. data/lib/dry/schema/macros/core.rb +1 -1
  20. data/lib/dry/schema/macros/dsl.rb +17 -15
  21. data/lib/dry/schema/macros/hash.rb +1 -1
  22. data/lib/dry/schema/macros/key.rb +2 -2
  23. data/lib/dry/schema/macros/schema.rb +2 -0
  24. data/lib/dry/schema/macros/value.rb +7 -0
  25. data/lib/dry/schema/message/or/multi_path.rb +7 -5
  26. data/lib/dry/schema/message_compiler.rb +13 -10
  27. data/lib/dry/schema/messages/abstract.rb +9 -9
  28. data/lib/dry/schema/messages/i18n.rb +98 -96
  29. data/lib/dry/schema/messages/namespaced.rb +6 -0
  30. data/lib/dry/schema/messages/yaml.rb +165 -158
  31. data/lib/dry/schema/predicate.rb +2 -2
  32. data/lib/dry/schema/predicate_inferrer.rb +2 -0
  33. data/lib/dry/schema/primitive_inferrer.rb +2 -0
  34. data/lib/dry/schema/processor.rb +4 -4
  35. data/lib/dry/schema/result.rb +5 -7
  36. data/lib/dry/schema/trace.rb +5 -1
  37. data/lib/dry/schema/type_registry.rb +1 -2
  38. data/lib/dry/schema/version.rb +1 -1
  39. metadata +9 -7
@@ -185,13 +185,11 @@ module Dry
185
185
  "#<#{self.class}#{to_h.inspect} errors=#{errors.to_h.inspect} path=#{path.keys.inspect}>"
186
186
  end
187
187
 
188
- if RUBY_VERSION >= "2.7"
189
- # Pattern matching support
190
- #
191
- # @api private
192
- def deconstruct_keys(_)
193
- output
194
- end
188
+ # Pattern matching support
189
+ #
190
+ # @api private
191
+ def deconstruct_keys(_)
192
+ output
195
193
  end
196
194
 
197
195
  # Add a new error AST node
@@ -89,6 +89,10 @@ module Dry
89
89
  captures.map(&:to_ast).map(&compiler.method(:visit)).reduce(:and)
90
90
  end
91
91
 
92
+ def respond_to_missing?(meth, include_private = false)
93
+ super || (meth.to_s.end_with?(QUESTION_MARK) && compuiler.support?(meth))
94
+ end
95
+
92
96
  # @api private
93
97
  def method_missing(meth, *args, &block)
94
98
  if meth.to_s.end_with?(QUESTION_MARK)
@@ -96,7 +100,7 @@ module Dry
96
100
  ::Kernel.raise InvalidSchemaError, "#{meth} predicate cannot be used in this context"
97
101
  end
98
102
 
99
- unless compiler.supports?(meth)
103
+ unless compiler.support?(meth)
100
104
  ::Kernel.raise ::ArgumentError, "#{meth} predicate is not defined"
101
105
  end
102
106
 
@@ -37,8 +37,7 @@ module Dry
37
37
  def [](name)
38
38
  key = [namespace, name].compact.join(DOT)
39
39
 
40
- type = types.registered?(key) ? types[key] : types[name.to_s]
41
- type
40
+ types.registered?(key) ? types[key] : types[name.to_s]
42
41
  end
43
42
  end
44
43
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Dry
4
4
  module Schema
5
- VERSION = "1.7.0"
5
+ VERSION = "1.9.1"
6
6
  end
7
7
  end
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.7.0
4
+ version: 1.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Solnica
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-29 00:00:00.000000000 Z
11
+ date: 2022-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -30,20 +30,20 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.8'
33
+ version: '0.13'
34
34
  - - ">="
35
35
  - !ruby/object:Gem::Version
36
- version: 0.8.3
36
+ version: 0.13.0
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - "~>"
42
42
  - !ruby/object:Gem::Version
43
- version: '0.8'
43
+ version: '0.13'
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: 0.8.3
46
+ version: 0.13.0
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: dry-core
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -178,6 +178,8 @@ files:
178
178
  - lib/dry/schema/extensions/hints/result_methods.rb
179
179
  - lib/dry/schema/extensions/info.rb
180
180
  - lib/dry/schema/extensions/info/schema_compiler.rb
181
+ - lib/dry/schema/extensions/json_schema.rb
182
+ - lib/dry/schema/extensions/json_schema/schema_compiler.rb
181
183
  - lib/dry/schema/extensions/monads.rb
182
184
  - lib/dry/schema/extensions/struct.rb
183
185
  - lib/dry/schema/json.rb
@@ -246,7 +248,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
246
248
  requirements:
247
249
  - - ">="
248
250
  - !ruby/object:Gem::Version
249
- version: 2.6.0
251
+ version: 2.7.0
250
252
  required_rubygems_version: !ruby/object:Gem::Requirement
251
253
  requirements:
252
254
  - - ">="