dry-schema 1.8.0 → 1.9.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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +54 -1
  3. data/README.md +4 -4
  4. data/dry-schema.gemspec +2 -2
  5. data/lib/dry/schema/compiler.rb +1 -1
  6. data/lib/dry/schema/dsl.rb +7 -4
  7. data/lib/dry/schema/extensions/hints/message_compiler_methods.rb +9 -4
  8. data/lib/dry/schema/extensions/hints.rb +11 -9
  9. data/lib/dry/schema/extensions/info/schema_compiler.rb +10 -1
  10. data/lib/dry/schema/extensions/json_schema/schema_compiler.rb +244 -0
  11. data/lib/dry/schema/extensions/json_schema.rb +29 -0
  12. data/lib/dry/schema/extensions/struct.rb +1 -1
  13. data/lib/dry/schema/extensions.rb +4 -0
  14. data/lib/dry/schema/key.rb +75 -74
  15. data/lib/dry/schema/key_coercer.rb +2 -2
  16. data/lib/dry/schema/key_validator.rb +44 -23
  17. data/lib/dry/schema/macros/array.rb +4 -0
  18. data/lib/dry/schema/macros/core.rb +1 -1
  19. data/lib/dry/schema/macros/dsl.rb +17 -15
  20. data/lib/dry/schema/macros/hash.rb +1 -1
  21. data/lib/dry/schema/macros/key.rb +2 -2
  22. data/lib/dry/schema/macros/schema.rb +2 -0
  23. data/lib/dry/schema/macros/value.rb +7 -0
  24. data/lib/dry/schema/message/or/multi_path.rb +73 -11
  25. data/lib/dry/schema/message/or.rb +2 -2
  26. data/lib/dry/schema/message_compiler.rb +13 -10
  27. data/lib/dry/schema/messages/i18n.rb +98 -96
  28. data/lib/dry/schema/messages/namespaced.rb +6 -0
  29. data/lib/dry/schema/messages/yaml.rb +165 -158
  30. data/lib/dry/schema/predicate.rb +2 -2
  31. data/lib/dry/schema/predicate_inferrer.rb +2 -0
  32. data/lib/dry/schema/primitive_inferrer.rb +2 -0
  33. data/lib/dry/schema/processor.rb +2 -2
  34. data/lib/dry/schema/result.rb +5 -7
  35. data/lib/dry/schema/trace.rb +5 -1
  36. data/lib/dry/schema/type_registry.rb +1 -2
  37. data/lib/dry/schema/version.rb +1 -1
  38. metadata +6 -4
@@ -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.8.0"
5
+ VERSION = "1.9.3"
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.8.0
4
+ version: 1.9.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: 2021-09-12 00:00:00.000000000 Z
11
+ date: 2022-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -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
@@ -235,7 +237,7 @@ licenses:
235
237
  - MIT
236
238
  metadata:
237
239
  allowed_push_host: https://rubygems.org
238
- changelog_uri: https://github.com/dry-rb/dry-schema/blob/master/CHANGELOG.md
240
+ changelog_uri: https://github.com/dry-rb/dry-schema/blob/main/CHANGELOG.md
239
241
  source_code_uri: https://github.com/dry-rb/dry-schema
240
242
  bug_tracker_uri: https://github.com/dry-rb/dry-schema/issues
241
243
  post_install_message:
@@ -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
  - - ">="