dry-schema 1.13.2 → 1.13.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f38923174afc15c94df3839a0ab0501c8aecb4ebc5df7042edc6c6590744449b
4
- data.tar.gz: 97183a67cd62d595ba32413708b99c6d4c3d6760414f846f9a2ee12a1fd15615
3
+ metadata.gz: 8a740c1cb0f62a33428ff5c187c9a93ce6fdd2dc567dd904f86e07d68d94f119
4
+ data.tar.gz: b25d1dc73b7f6a2a7161a06495e4f1d5e4dfd6bafc52ad2a2088018fe9ecaf10
5
5
  SHA512:
6
- metadata.gz: 70f7656a3c4af51c4d576d022ba552728831b35cadf29f2589706e979463a01d2a5eea1c5ed546759625431dc7114df41b2f1838e8bda2d1fa223c8573f5f8a1
7
- data.tar.gz: 6b639a89fb5df82cfcb546649a5cc172456537e11944913a48df2b88b99a04b0b09be262ce55224a1fdc7d87916e5cd5f6b73bad761972b010ca2034f7b13e77
6
+ metadata.gz: e914b3630c16022e6fb323a749ca66ad2dcff14ba24cff66f16b36fc102092ec9269d95e1f25dad3817eb4a44786d3a6a21d1fe7a930a75d63532a2fdcca663c
7
+ data.tar.gz: d0436db384cf03b10eed4a20717de7f06c12fdfa94426af6bae7e92c93c88efcbc851ad658f0370add6fc0ebf1bad9b636fdc7d41faf75299da3c57fa947e767
data/CHANGELOG.md CHANGED
@@ -1,5 +1,32 @@
1
1
  <!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
2
2
 
3
+ ## 1.13.4 2024-05-22
4
+
5
+
6
+ ### Added
7
+
8
+ - Default error message for `:uri?` (issue #476 via #477) (@timjnh)
9
+
10
+ ### Fixed
11
+
12
+ - Fix json-schema type of objects nested under arrays (issue #400 fixed via #462) (@tomgi)
13
+
14
+ ### Changed
15
+
16
+ - i18n backend is no longer eager-loaded (via 85a9e0b) (@adam12)
17
+
18
+ [Compare v1.13.3...v1.13.4](https://github.com/dry-rb/dry-schema/compare/v1.13.3...v1.13.4)
19
+
20
+ ## 1.13.3 2023-08-26
21
+
22
+
23
+ ### Fixed
24
+
25
+ - Fix struct extension for nested struct definitions (via #466) (@flash-gordon)
26
+
27
+
28
+ [Compare v1.13.2...v1.13.3](https://github.com/dry-rb/dry-schema/compare/v1.13.2...v1.13.3)
29
+
3
30
  ## 1.13.2 2023-05-31
4
31
 
5
32
 
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
  [gem]: https://rubygems.org/gems/dry-schema
3
3
  [actions]: https://github.com/dry-rb/dry-schema/actions
4
4
 
5
- # dry-schema [![Gem Version](https://badge.fury.io/rb/dry-schema.svg)][gem] [![CI Status](https://github.com/dry-rb/dry-schema/workflows/ci/badge.svg)][actions]
5
+ # dry-schema [![Gem Version](https://badge.fury.io/rb/dry-schema.svg)][gem] [![CI Status](https://github.com/dry-rb/dry-schema/workflows/CI/badge.svg)][actions]
6
6
 
7
7
  ## Links
8
8
 
data/config/errors.yml CHANGED
@@ -107,5 +107,7 @@ en:
107
107
 
108
108
  uuid_v4?: "is not a valid UUID"
109
109
 
110
+ uri?: "is not a valid URI"
111
+
110
112
  not:
111
113
  empty?: "cannot be empty"
@@ -90,7 +90,7 @@ module Dry
90
90
  def visit_set(node, opts = EMPTY_HASH)
91
91
  target = (key = opts[:key]) ? self.class.new(loose: loose?) : self
92
92
 
93
- node.map { |child| target.visit(child, opts) }
93
+ node.map { |child| target.visit(child, opts.except(:member)) }
94
94
 
95
95
  return unless key
96
96
 
@@ -5,20 +5,42 @@ require "dry/struct"
5
5
  module Dry
6
6
  module Schema
7
7
  module Macros
8
+ class StructToSchema < ::Dry::Struct::Compiler
9
+ def call(struct)
10
+ visit(struct.to_ast)
11
+ end
12
+
13
+ # strip away structs from AST
14
+ def visit_struct(node)
15
+ _, ast = node
16
+ visit(ast)
17
+ end
18
+ end
19
+
20
+ Hash.option :struct_compiler, default: proc { StructToSchema.new(schema_dsl.config.types) }
21
+
8
22
  Hash.prepend(::Module.new {
9
23
  def call(*args)
10
- if args.size >= 1 && args[0].is_a?(::Class) && args[0] <= ::Dry::Struct
24
+ if args.size >= 1 && struct?(args[0])
11
25
  if block_given?
12
26
  raise ArgumentError, "blocks are not supported when using "\
13
27
  "a struct class (#{name.inspect} => #{args[0]})"
14
28
  end
15
29
 
16
- super(args[0].schema, *args.drop(1))
17
- type(schema_dsl.types[name].constructor(args[0].schema))
30
+ schema = struct_compiler.(args[0])
31
+
32
+ super(schema, *args.drop(1))
33
+ type(schema_dsl.types[name].constructor(schema))
18
34
  else
19
35
  super
20
36
  end
21
37
  end
38
+
39
+ private
40
+
41
+ def struct?(type)
42
+ type.is_a?(::Class) && type <= ::Dry::Struct
43
+ end
22
44
  })
23
45
  end
24
46
 
@@ -9,8 +9,8 @@ module Dry
9
9
  class KeyValidator
10
10
  extend Dry::Initializer
11
11
 
12
- INDEX_REGEX = /\[\d+\]/.freeze
13
- DIGIT_REGEX = /\A\d+\z/.freeze
12
+ INDEX_REGEX = /\[\d+\]/
13
+ DIGIT_REGEX = /\A\d+\z/
14
14
  BRACKETS = "[]"
15
15
 
16
16
  # @api private
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Dry
4
4
  module Schema
5
- VERSION = "1.13.2"
5
+ VERSION = "1.13.4"
6
6
  end
7
7
  end
data/lib/dry/schema.rb CHANGED
@@ -32,6 +32,7 @@ module Dry
32
32
  "#{root}/dry/schema/{constants,errors,version,extensions}.rb",
33
33
  "#{root}/dry/schema/extensions"
34
34
  )
35
+ loader.do_not_eager_load("#{root}/dry/schema/messages/i18n.rb")
35
36
  loader.inflector.inflect("dsl" => "DSL")
36
37
  end
37
38
  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.13.2
4
+ version: 1.13.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Solnica
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-31 00:00:00.000000000 Z
11
+ date: 2024-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -281,7 +281,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
281
281
  - !ruby/object:Gem::Version
282
282
  version: '0'
283
283
  requirements: []
284
- rubygems_version: 3.3.26
284
+ rubygems_version: 3.3.27
285
285
  signing_key:
286
286
  specification_version: 4
287
287
  summary: Coercion and validation for data structures