dry-validation 1.9.0 → 1.11.0
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 +20 -0
- data/LICENSE +1 -1
- data/README.md +5 -12
- data/dry-validation.gemspec +13 -16
- data/lib/dry/validation/constants.rb +6 -6
- data/lib/dry/validation/contract/class_interface.rb +8 -8
- data/lib/dry/validation/contract.rb +11 -3
- data/lib/dry/validation/evaluator.rb +4 -5
- data/lib/dry/validation/extensions/hints.rb +1 -1
- data/lib/dry/validation/extensions/monads.rb +7 -2
- data/lib/dry/validation/failures.rb +1 -1
- data/lib/dry/validation/macros.rb +5 -7
- data/lib/dry/validation/message.rb +1 -1
- data/lib/dry/validation/messages/resolver.rb +5 -5
- data/lib/dry/validation/result.rb +12 -14
- data/lib/dry/validation/rule.rb +2 -2
- data/lib/dry/validation/schema_ext.rb +1 -1
- data/lib/dry/validation/values.rb +13 -18
- data/lib/dry/validation/version.rb +1 -1
- data/lib/dry/validation.rb +2 -2
- metadata +14 -87
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c326a1534dbb87a166682a21d9f60228f0bf68086b4ec27cbcb0fc01ad20a945
|
|
4
|
+
data.tar.gz: 2c01562734f8c6a6c03d0015843f3cff56f53a185f91f4aa8a3f563130c293e5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f961a54ed17568337a245bff5b7eb4254ebafcf545d148b2e6d76d798e48ec1adc57c20df590834cc4e7377a7f3576ddd065dfa964a77887a7cbb1a3c8130035
|
|
7
|
+
data.tar.gz: fe5fab776a9f7d4fce8208cf6207234c7f53b1d5ac8d686b705f757b569ec4b67ffa8344da013eeb5f30b947015d5be54cef1a8f9c54fab93e7ac9c7f89e1a71
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
<!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
|
|
2
2
|
|
|
3
|
+
## 1.11.0 2025-01-06
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Changed
|
|
7
|
+
|
|
8
|
+
- Passing non-hash values to `Contract#call` now raises a meaningful error (issue #716 via #723) (@flash-gordon)
|
|
9
|
+
- Set minimum Ruby version to 3.1 (@flash-gordon)
|
|
10
|
+
|
|
11
|
+
[Compare v1.10.0...v1.11.0](https://github.com/dry-rb/dry-validation/compare/v1.10.0...v1.11.0)
|
|
12
|
+
|
|
13
|
+
## 1.10.0 2022-11-04
|
|
14
|
+
|
|
15
|
+
This release is mostly about upgrading to dry-core 1.0 and dry-configurable 1.0. One of the outcomes is dropping dependency on dry-container (because it was moved to dry-core). If you happen to use dry-container, please switch to `Dry::Core::Container`.
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- Upgraded to the latest versions of dry-{core,configurable,logic,types} (@flash-gordon + @solnic)
|
|
20
|
+
|
|
21
|
+
[Compare v1.9.0...v1.10.0](https://github.com/dry-rb/dry-validation/compare/v1.9.0...v1.10.0)
|
|
22
|
+
|
|
3
23
|
## 1.9.0 2022-10-15
|
|
4
24
|
|
|
5
25
|
|
data/LICENSE
CHANGED
data/README.md
CHANGED
|
@@ -1,29 +1,22 @@
|
|
|
1
1
|
<!--- this file is synced from dry-rb/template-gem project -->
|
|
2
|
+
|
|
2
3
|
[gem]: https://rubygems.org/gems/dry-validation
|
|
3
4
|
[actions]: https://github.com/dry-rb/dry-validation/actions
|
|
4
|
-
[codacy]: https://www.codacy.com/gh/dry-rb/dry-validation
|
|
5
|
-
[chat]: https://dry-rb.zulipchat.com
|
|
6
|
-
[inchpages]: http://inch-ci.org/github/dry-rb/dry-validation
|
|
7
|
-
|
|
8
|
-
# dry-validation [][chat]
|
|
9
5
|
|
|
10
|
-
[][gem]
|
|
11
|
-
[][actions]
|
|
12
|
-
[][codacy]
|
|
13
|
-
[][codacy]
|
|
14
|
-
[][inchpages]
|
|
6
|
+
# dry-validation [][gem] [][actions]
|
|
15
7
|
|
|
16
8
|
## Links
|
|
17
9
|
|
|
18
10
|
* [User documentation](https://dry-rb.org/gems/dry-validation)
|
|
19
11
|
* [API documentation](http://rubydoc.info/gems/dry-validation)
|
|
12
|
+
* [Forum](https://discourse.dry-rb.org)
|
|
20
13
|
|
|
21
14
|
## Supported Ruby versions
|
|
22
15
|
|
|
23
16
|
This library officially supports the following Ruby versions:
|
|
24
17
|
|
|
25
|
-
* MRI `>=
|
|
26
|
-
* jruby `>= 9.
|
|
18
|
+
* MRI `>= 3.1`
|
|
19
|
+
* jruby `>= 9.4` (not tested on CI)
|
|
27
20
|
|
|
28
21
|
## License
|
|
29
22
|
|
data/dry-validation.gemspec
CHANGED
|
@@ -16,27 +16,24 @@ Gem::Specification.new do |spec|
|
|
|
16
16
|
spec.summary = "Validation library"
|
|
17
17
|
spec.description = spec.summary
|
|
18
18
|
spec.homepage = "https://dry-rb.org/gems/dry-validation"
|
|
19
|
-
spec.files = Dir["CHANGELOG.md", "LICENSE", "README.md", "dry-validation.gemspec",
|
|
19
|
+
spec.files = Dir["CHANGELOG.md", "LICENSE", "README.md", "dry-validation.gemspec",
|
|
20
|
+
"lib/**/*", "config/*.yml"]
|
|
20
21
|
spec.bindir = "bin"
|
|
21
22
|
spec.executables = []
|
|
22
23
|
spec.require_paths = ["lib"]
|
|
23
24
|
|
|
24
|
-
spec.metadata["allowed_push_host"]
|
|
25
|
-
spec.metadata["changelog_uri"]
|
|
26
|
-
spec.metadata["source_code_uri"]
|
|
27
|
-
spec.metadata["bug_tracker_uri"]
|
|
25
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
|
26
|
+
spec.metadata["changelog_uri"] = "https://github.com/dry-rb/dry-validation/blob/main/CHANGELOG.md"
|
|
27
|
+
spec.metadata["source_code_uri"] = "https://github.com/dry-rb/dry-validation"
|
|
28
|
+
spec.metadata["bug_tracker_uri"] = "https://github.com/dry-rb/dry-validation/issues"
|
|
29
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
|
28
30
|
|
|
29
|
-
spec.required_ruby_version = ">=
|
|
31
|
+
spec.required_ruby_version = ">= 3.1"
|
|
30
32
|
|
|
31
33
|
# to update dependencies edit project.yml
|
|
32
|
-
spec.
|
|
33
|
-
spec.
|
|
34
|
-
spec.
|
|
35
|
-
spec.
|
|
36
|
-
spec.
|
|
37
|
-
spec.add_runtime_dependency "zeitwerk", "~> 2.6"
|
|
38
|
-
|
|
39
|
-
spec.add_development_dependency "bundler"
|
|
40
|
-
spec.add_development_dependency "rake"
|
|
41
|
-
spec.add_development_dependency "rspec"
|
|
34
|
+
spec.add_dependency "concurrent-ruby", "~> 1.0"
|
|
35
|
+
spec.add_dependency "dry-core", "~> 1.1"
|
|
36
|
+
spec.add_dependency "dry-initializer", "~> 3.2"
|
|
37
|
+
spec.add_dependency "dry-schema", "~> 1.14"
|
|
38
|
+
spec.add_dependency "zeitwerk", "~> 2.6"
|
|
42
39
|
end
|
|
@@ -5,7 +5,7 @@ require "dry/core/constants"
|
|
|
5
5
|
|
|
6
6
|
module Dry
|
|
7
7
|
module Validation
|
|
8
|
-
include Dry::Core::Constants
|
|
8
|
+
include ::Dry::Core::Constants
|
|
9
9
|
|
|
10
10
|
DOT = "."
|
|
11
11
|
|
|
@@ -21,19 +21,19 @@ module Dry
|
|
|
21
21
|
# Mapping for block kwarg options used by block_options
|
|
22
22
|
#
|
|
23
23
|
# @see Rule#block_options
|
|
24
|
-
BLOCK_OPTIONS_MAPPINGS = Hash.new { |_, key| key }.update(context: :_context).freeze
|
|
24
|
+
BLOCK_OPTIONS_MAPPINGS = ::Hash.new { |_, key| key }.update(context: :_context).freeze
|
|
25
25
|
|
|
26
26
|
# Error raised when `rule` specifies one or more keys that the schema doesn't specify
|
|
27
|
-
InvalidKeysError = Class.new(StandardError)
|
|
27
|
+
InvalidKeysError = ::Class.new(::StandardError)
|
|
28
28
|
|
|
29
29
|
# Error raised when a localized message was not found
|
|
30
|
-
MissingMessageError = Class.new(StandardError)
|
|
30
|
+
MissingMessageError = ::Class.new(::StandardError)
|
|
31
31
|
|
|
32
32
|
# Error raised when trying to define a schema in a contract class that already has a schema
|
|
33
|
-
DuplicateSchemaError = Class.new(StandardError)
|
|
33
|
+
DuplicateSchemaError = ::Class.new(::StandardError)
|
|
34
34
|
|
|
35
35
|
# Error raised during initialization of a contract that has no schema defined
|
|
36
|
-
SchemaMissingError = Class.new(StandardError) do
|
|
36
|
+
SchemaMissingError = ::Class.new(::StandardError) do
|
|
37
37
|
# @api private
|
|
38
38
|
def initialize(klass)
|
|
39
39
|
super("#{klass} cannot be instantiated without a schema defined")
|
|
@@ -50,8 +50,8 @@ module Dry
|
|
|
50
50
|
# @see https://dry-rb.org/gems/dry-schema/params/
|
|
51
51
|
#
|
|
52
52
|
# @api public
|
|
53
|
-
def params(*external_schemas, &
|
|
54
|
-
define(:Params, external_schemas, &
|
|
53
|
+
def params(*external_schemas, &)
|
|
54
|
+
define(:Params, external_schemas, &)
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
# Define a JSON schema for your contract
|
|
@@ -62,8 +62,8 @@ module Dry
|
|
|
62
62
|
# @see https://dry-rb.org/gems/dry-schema/json/
|
|
63
63
|
#
|
|
64
64
|
# @api public
|
|
65
|
-
def json(*external_schemas, &
|
|
66
|
-
define(:JSON, external_schemas, &
|
|
65
|
+
def json(*external_schemas, &)
|
|
66
|
+
define(:JSON, external_schemas, &)
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
# Define a plain schema for your contract
|
|
@@ -74,8 +74,8 @@ module Dry
|
|
|
74
74
|
# @see https://dry-rb.org/gems/dry-schema/
|
|
75
75
|
#
|
|
76
76
|
# @api public
|
|
77
|
-
def schema(*external_schemas, &
|
|
78
|
-
define(:schema, external_schemas, &
|
|
77
|
+
def schema(*external_schemas, &)
|
|
78
|
+
define(:schema, external_schemas, &)
|
|
79
79
|
end
|
|
80
80
|
|
|
81
81
|
# Define a rule for your contract
|
|
@@ -115,8 +115,8 @@ module Dry
|
|
|
115
115
|
# @return [Contract]
|
|
116
116
|
#
|
|
117
117
|
# @api public
|
|
118
|
-
def build(options = EMPTY_HASH, &
|
|
119
|
-
Class.new(self, &
|
|
118
|
+
def build(options = EMPTY_HASH, &)
|
|
119
|
+
Class.new(self, &).new(**options)
|
|
120
120
|
end
|
|
121
121
|
|
|
122
122
|
# @api private
|
|
@@ -41,9 +41,9 @@ module Dry
|
|
|
41
41
|
#
|
|
42
42
|
# @api public
|
|
43
43
|
class Contract
|
|
44
|
-
include Dry::Equalizer(:schema, :rules, :messages, inspect: false)
|
|
44
|
+
include ::Dry::Equalizer(:schema, :rules, :messages, inspect: false)
|
|
45
45
|
|
|
46
|
-
extend Dry::Initializer
|
|
46
|
+
extend ::Dry::Initializer
|
|
47
47
|
extend ClassInterface
|
|
48
48
|
|
|
49
49
|
config.messages.top_namespace = DEFAULT_ERRORS_NAMESPACE
|
|
@@ -90,7 +90,9 @@ module Dry
|
|
|
90
90
|
# @api public
|
|
91
91
|
# rubocop: disable Metrics/AbcSize
|
|
92
92
|
def call(input, context = EMPTY_HASH)
|
|
93
|
-
|
|
93
|
+
validate_input_type(input)
|
|
94
|
+
|
|
95
|
+
context_map = ::Concurrent::Map.new.tap do |map|
|
|
94
96
|
default_context.each { |key, value| map[key] = value }
|
|
95
97
|
context.each { |key, value| map[key] = value }
|
|
96
98
|
end
|
|
@@ -161,6 +163,12 @@ module Dry
|
|
|
161
163
|
def messages
|
|
162
164
|
self.class.messages
|
|
163
165
|
end
|
|
166
|
+
|
|
167
|
+
def validate_input_type(input)
|
|
168
|
+
return if input.is_a?(::Hash)
|
|
169
|
+
|
|
170
|
+
raise ::ArgumentError, "Input must be a Hash. #{input.class} was given."
|
|
171
|
+
end
|
|
164
172
|
end
|
|
165
173
|
end
|
|
166
174
|
end
|
|
@@ -117,8 +117,8 @@ module Dry
|
|
|
117
117
|
end
|
|
118
118
|
|
|
119
119
|
# @api private
|
|
120
|
-
def with(new_opts, &
|
|
121
|
-
self.class.new(_contract, **_options, **new_opts, &
|
|
120
|
+
def with(new_opts, &)
|
|
121
|
+
self.class.new(_contract, **_options, **new_opts, &)
|
|
122
122
|
end
|
|
123
123
|
|
|
124
124
|
# Return default (first) key name
|
|
@@ -216,15 +216,14 @@ module Dry
|
|
|
216
216
|
# Forward to the underlying contract
|
|
217
217
|
#
|
|
218
218
|
# @api private
|
|
219
|
-
def method_missing(meth,
|
|
219
|
+
def method_missing(meth, ...)
|
|
220
220
|
# yes, we do want to delegate to private methods too
|
|
221
221
|
if _contract.respond_to?(meth, true)
|
|
222
|
-
_contract.__send__(meth,
|
|
222
|
+
_contract.__send__(meth, ...)
|
|
223
223
|
else
|
|
224
224
|
super
|
|
225
225
|
end
|
|
226
226
|
end
|
|
227
|
-
ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
|
|
228
227
|
end
|
|
229
228
|
end
|
|
230
229
|
end
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "dry/monads
|
|
3
|
+
require "dry/monads"
|
|
4
|
+
require "dry/monads/version"
|
|
5
|
+
|
|
6
|
+
if Gem::Version.new(Dry::Monads::VERSION) < Gem::Version.new("1.6.0")
|
|
7
|
+
raise "dry-validation requires dry-monads >= 1.6.0"
|
|
8
|
+
end
|
|
4
9
|
|
|
5
10
|
module Dry
|
|
6
11
|
module Validation
|
|
@@ -19,7 +24,7 @@ module Dry
|
|
|
19
24
|
#
|
|
20
25
|
# @api public
|
|
21
26
|
class Result
|
|
22
|
-
include Dry::Monads::Result::Mixin
|
|
27
|
+
include ::Dry::Monads::Result::Mixin
|
|
23
28
|
|
|
24
29
|
# Returns a result monad
|
|
25
30
|
#
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "dry/container"
|
|
4
|
-
|
|
5
3
|
module Dry
|
|
6
4
|
module Validation
|
|
7
5
|
# API for registering and accessing Rule macros
|
|
@@ -31,8 +29,8 @@ module Dry
|
|
|
31
29
|
# @see Macro
|
|
32
30
|
#
|
|
33
31
|
# @api public
|
|
34
|
-
def register_macro(
|
|
35
|
-
macros.register(
|
|
32
|
+
def register_macro(...)
|
|
33
|
+
macros.register(...)
|
|
36
34
|
self
|
|
37
35
|
end
|
|
38
36
|
end
|
|
@@ -41,7 +39,7 @@ module Dry
|
|
|
41
39
|
#
|
|
42
40
|
# @api public
|
|
43
41
|
class Container
|
|
44
|
-
include
|
|
42
|
+
include Core::Container::Mixin
|
|
45
43
|
|
|
46
44
|
# Register a new macro
|
|
47
45
|
#
|
|
@@ -82,8 +80,8 @@ module Dry
|
|
|
82
80
|
# @return [Macros]
|
|
83
81
|
#
|
|
84
82
|
# @api public
|
|
85
|
-
def self.register(name,
|
|
86
|
-
container.register(name,
|
|
83
|
+
def self.register(name, ...)
|
|
84
|
+
container.register(name, ...)
|
|
87
85
|
self
|
|
88
86
|
end
|
|
89
87
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module Dry
|
|
4
4
|
module Validation
|
|
5
5
|
module Messages
|
|
6
|
-
FULL_MESSAGE_WHITESPACE = Dry::Schema::MessageCompiler::FULL_MESSAGE_WHITESPACE
|
|
6
|
+
FULL_MESSAGE_WHITESPACE = ::Dry::Schema::MessageCompiler::FULL_MESSAGE_WHITESPACE
|
|
7
7
|
|
|
8
8
|
# Resolve translated messages from failure arguments
|
|
9
9
|
#
|
|
@@ -30,11 +30,11 @@ module Dry
|
|
|
30
30
|
# @api public
|
|
31
31
|
def call(message:, tokens:, path:, meta: EMPTY_HASH)
|
|
32
32
|
case message
|
|
33
|
-
when Symbol
|
|
33
|
+
when ::Symbol
|
|
34
34
|
Message[->(**opts) { message(message, path: path, tokens: tokens, **opts) }, path, meta]
|
|
35
|
-
when String
|
|
35
|
+
when ::String
|
|
36
36
|
Message[->(**opts) { [message_text(message, path: path, **opts), meta] }, path, meta]
|
|
37
|
-
when Hash
|
|
37
|
+
when ::Hash
|
|
38
38
|
meta = message.dup
|
|
39
39
|
text = meta.delete(:text) { |key|
|
|
40
40
|
raise ArgumentError, <<~STR
|
|
@@ -114,7 +114,7 @@ module Dry
|
|
|
114
114
|
|
|
115
115
|
def parse_token(token)
|
|
116
116
|
case token
|
|
117
|
-
when Array
|
|
117
|
+
when ::Array
|
|
118
118
|
token.join(", ")
|
|
119
119
|
else
|
|
120
120
|
token
|
|
@@ -10,7 +10,7 @@ module Dry
|
|
|
10
10
|
#
|
|
11
11
|
# @api public
|
|
12
12
|
class Result
|
|
13
|
-
include Dry::Equalizer(:schema_result, :context, :errors, inspect: false)
|
|
13
|
+
include ::Dry::Equalizer(:schema_result, :context, :errors, inspect: false)
|
|
14
14
|
|
|
15
15
|
# Build a new result
|
|
16
16
|
#
|
|
@@ -197,20 +197,18 @@ module Dry
|
|
|
197
197
|
super
|
|
198
198
|
end
|
|
199
199
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
end
|
|
200
|
+
# Pattern matching
|
|
201
|
+
#
|
|
202
|
+
# @api private
|
|
203
|
+
def deconstruct_keys(keys)
|
|
204
|
+
values.deconstruct_keys(keys)
|
|
205
|
+
end
|
|
207
206
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
end
|
|
207
|
+
# Pattern matching
|
|
208
|
+
#
|
|
209
|
+
# @api private
|
|
210
|
+
def deconstruct
|
|
211
|
+
[values, context.each.to_h]
|
|
214
212
|
end
|
|
215
213
|
|
|
216
214
|
private
|
data/lib/dry/validation/rule.rb
CHANGED
|
@@ -13,7 +13,7 @@ module Dry
|
|
|
13
13
|
#
|
|
14
14
|
# @api public
|
|
15
15
|
class Rule < Function
|
|
16
|
-
include Dry::Equalizer(:keys, :block, inspect: false)
|
|
16
|
+
include ::Dry::Equalizer(:keys, :block, inspect: false)
|
|
17
17
|
|
|
18
18
|
# @!attribute [r] keys
|
|
19
19
|
# @return [Array<Symbol, String, Hash>]
|
|
@@ -127,7 +127,7 @@ module Dry
|
|
|
127
127
|
|
|
128
128
|
def add_macro_from_hash(macros, spec)
|
|
129
129
|
spec.each do |k, v|
|
|
130
|
-
macros << [k, v.is_a?(Array) ? v : [v]]
|
|
130
|
+
macros << [k, v.is_a?(::Array) ? v : [v]]
|
|
131
131
|
end
|
|
132
132
|
end
|
|
133
133
|
end
|
|
@@ -12,8 +12,8 @@ module Dry
|
|
|
12
12
|
#
|
|
13
13
|
# @api public
|
|
14
14
|
class Values
|
|
15
|
-
include Enumerable
|
|
16
|
-
include Dry::Equalizer(:data)
|
|
15
|
+
include ::Enumerable
|
|
16
|
+
include ::Dry::Equalizer(:data)
|
|
17
17
|
|
|
18
18
|
# Schema's result output
|
|
19
19
|
#
|
|
@@ -46,8 +46,8 @@ module Dry
|
|
|
46
46
|
return data.dig(*args) if args.size > 1
|
|
47
47
|
|
|
48
48
|
case (key = args[0])
|
|
49
|
-
when Symbol, String, Array, Hash
|
|
50
|
-
keys = Schema::Path[key].to_a
|
|
49
|
+
when ::Symbol, ::String, ::Array, ::Hash
|
|
50
|
+
keys = ::Dry::Schema::Path[key].to_a
|
|
51
51
|
|
|
52
52
|
return data.dig(*keys) unless keys.last.is_a?(Array)
|
|
53
53
|
|
|
@@ -55,28 +55,24 @@ module Dry
|
|
|
55
55
|
vals = self.class.new(data.dig(*keys))
|
|
56
56
|
vals.fetch_values(*last) { nil }
|
|
57
57
|
else
|
|
58
|
-
raise ArgumentError, "+key+ must be a valid path specification"
|
|
58
|
+
raise ::ArgumentError, "+key+ must be a valid path specification"
|
|
59
59
|
end
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
# @api public
|
|
63
63
|
# rubocop: disable Metrics/PerceivedComplexity
|
|
64
64
|
def key?(key, hash = data)
|
|
65
|
-
return hash.key?(key) if key.is_a?(Symbol)
|
|
65
|
+
return hash.key?(key) if key.is_a?(::Symbol)
|
|
66
66
|
|
|
67
67
|
Schema::Path[key].reduce(hash) do |a, e|
|
|
68
|
-
if e.is_a?(Array)
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
elsif e.is_a?(Symbol) && a.is_a?(Array)
|
|
72
|
-
return false
|
|
73
|
-
elsif a.nil?
|
|
74
|
-
return false
|
|
75
|
-
elsif a.is_a?(String)
|
|
68
|
+
if e.is_a?(::Array)
|
|
69
|
+
return e.all? { |k| key?(k, a) }
|
|
70
|
+
elsif (e.is_a?(::Symbol) && a.is_a?(::Array)) || a.nil? || a.is_a?(::String)
|
|
76
71
|
return false
|
|
77
72
|
else
|
|
78
|
-
return false unless a.is_a?(Array) ? (e >= 0 && e < a.size) : a.key?(e)
|
|
73
|
+
return false unless a.is_a?(::Array) ? (e >= 0 && e < a.size) : a.key?(e)
|
|
79
74
|
end
|
|
75
|
+
|
|
80
76
|
a[e]
|
|
81
77
|
end
|
|
82
78
|
true
|
|
@@ -91,14 +87,13 @@ module Dry
|
|
|
91
87
|
private
|
|
92
88
|
|
|
93
89
|
# @api private
|
|
94
|
-
def method_missing(meth,
|
|
90
|
+
def method_missing(meth, ...)
|
|
95
91
|
if data.respond_to?(meth)
|
|
96
|
-
data.public_send(meth,
|
|
92
|
+
data.public_send(meth, ...)
|
|
97
93
|
else
|
|
98
94
|
super
|
|
99
95
|
end
|
|
100
96
|
end
|
|
101
|
-
ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
|
|
102
97
|
end
|
|
103
98
|
end
|
|
104
99
|
end
|
data/lib/dry/validation.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dry-validation
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.11.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Piotr Solnica
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2025-01-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: concurrent-ruby
|
|
@@ -24,80 +24,48 @@ dependencies:
|
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '1.0'
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: dry-container
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - "~>"
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: '0.7'
|
|
34
|
-
- - ">="
|
|
35
|
-
- !ruby/object:Gem::Version
|
|
36
|
-
version: 0.7.1
|
|
37
|
-
type: :runtime
|
|
38
|
-
prerelease: false
|
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
40
|
-
requirements:
|
|
41
|
-
- - "~>"
|
|
42
|
-
- !ruby/object:Gem::Version
|
|
43
|
-
version: '0.7'
|
|
44
|
-
- - ">="
|
|
45
|
-
- !ruby/object:Gem::Version
|
|
46
|
-
version: 0.7.1
|
|
47
27
|
- !ruby/object:Gem::Dependency
|
|
48
28
|
name: dry-core
|
|
49
29
|
requirement: !ruby/object:Gem::Requirement
|
|
50
30
|
requirements:
|
|
51
31
|
- - "~>"
|
|
52
32
|
- !ruby/object:Gem::Version
|
|
53
|
-
version: '
|
|
54
|
-
- - ">="
|
|
55
|
-
- !ruby/object:Gem::Version
|
|
56
|
-
version: '0.9'
|
|
33
|
+
version: '1.1'
|
|
57
34
|
type: :runtime
|
|
58
35
|
prerelease: false
|
|
59
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
60
37
|
requirements:
|
|
61
38
|
- - "~>"
|
|
62
39
|
- !ruby/object:Gem::Version
|
|
63
|
-
version: '
|
|
64
|
-
- - ">="
|
|
65
|
-
- !ruby/object:Gem::Version
|
|
66
|
-
version: '0.9'
|
|
40
|
+
version: '1.1'
|
|
67
41
|
- !ruby/object:Gem::Dependency
|
|
68
42
|
name: dry-initializer
|
|
69
43
|
requirement: !ruby/object:Gem::Requirement
|
|
70
44
|
requirements:
|
|
71
45
|
- - "~>"
|
|
72
46
|
- !ruby/object:Gem::Version
|
|
73
|
-
version: '3.
|
|
47
|
+
version: '3.2'
|
|
74
48
|
type: :runtime
|
|
75
49
|
prerelease: false
|
|
76
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
77
51
|
requirements:
|
|
78
52
|
- - "~>"
|
|
79
53
|
- !ruby/object:Gem::Version
|
|
80
|
-
version: '3.
|
|
54
|
+
version: '3.2'
|
|
81
55
|
- !ruby/object:Gem::Dependency
|
|
82
56
|
name: dry-schema
|
|
83
57
|
requirement: !ruby/object:Gem::Requirement
|
|
84
58
|
requirements:
|
|
85
59
|
- - "~>"
|
|
86
60
|
- !ruby/object:Gem::Version
|
|
87
|
-
version: '1.
|
|
88
|
-
- - ">="
|
|
89
|
-
- !ruby/object:Gem::Version
|
|
90
|
-
version: 1.11.0
|
|
61
|
+
version: '1.14'
|
|
91
62
|
type: :runtime
|
|
92
63
|
prerelease: false
|
|
93
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
94
65
|
requirements:
|
|
95
66
|
- - "~>"
|
|
96
67
|
- !ruby/object:Gem::Version
|
|
97
|
-
version: '1.
|
|
98
|
-
- - ">="
|
|
99
|
-
- !ruby/object:Gem::Version
|
|
100
|
-
version: 1.11.0
|
|
68
|
+
version: '1.14'
|
|
101
69
|
- !ruby/object:Gem::Dependency
|
|
102
70
|
name: zeitwerk
|
|
103
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -112,48 +80,6 @@ dependencies:
|
|
|
112
80
|
- - "~>"
|
|
113
81
|
- !ruby/object:Gem::Version
|
|
114
82
|
version: '2.6'
|
|
115
|
-
- !ruby/object:Gem::Dependency
|
|
116
|
-
name: bundler
|
|
117
|
-
requirement: !ruby/object:Gem::Requirement
|
|
118
|
-
requirements:
|
|
119
|
-
- - ">="
|
|
120
|
-
- !ruby/object:Gem::Version
|
|
121
|
-
version: '0'
|
|
122
|
-
type: :development
|
|
123
|
-
prerelease: false
|
|
124
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
125
|
-
requirements:
|
|
126
|
-
- - ">="
|
|
127
|
-
- !ruby/object:Gem::Version
|
|
128
|
-
version: '0'
|
|
129
|
-
- !ruby/object:Gem::Dependency
|
|
130
|
-
name: rake
|
|
131
|
-
requirement: !ruby/object:Gem::Requirement
|
|
132
|
-
requirements:
|
|
133
|
-
- - ">="
|
|
134
|
-
- !ruby/object:Gem::Version
|
|
135
|
-
version: '0'
|
|
136
|
-
type: :development
|
|
137
|
-
prerelease: false
|
|
138
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
139
|
-
requirements:
|
|
140
|
-
- - ">="
|
|
141
|
-
- !ruby/object:Gem::Version
|
|
142
|
-
version: '0'
|
|
143
|
-
- !ruby/object:Gem::Dependency
|
|
144
|
-
name: rspec
|
|
145
|
-
requirement: !ruby/object:Gem::Requirement
|
|
146
|
-
requirements:
|
|
147
|
-
- - ">="
|
|
148
|
-
- !ruby/object:Gem::Version
|
|
149
|
-
version: '0'
|
|
150
|
-
type: :development
|
|
151
|
-
prerelease: false
|
|
152
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
153
|
-
requirements:
|
|
154
|
-
- - ">="
|
|
155
|
-
- !ruby/object:Gem::Version
|
|
156
|
-
version: '0'
|
|
157
83
|
description: Validation library
|
|
158
84
|
email:
|
|
159
85
|
- piotr.solnica@gmail.com
|
|
@@ -196,7 +122,8 @@ metadata:
|
|
|
196
122
|
changelog_uri: https://github.com/dry-rb/dry-validation/blob/main/CHANGELOG.md
|
|
197
123
|
source_code_uri: https://github.com/dry-rb/dry-validation
|
|
198
124
|
bug_tracker_uri: https://github.com/dry-rb/dry-validation/issues
|
|
199
|
-
|
|
125
|
+
rubygems_mfa_required: 'true'
|
|
126
|
+
post_install_message:
|
|
200
127
|
rdoc_options: []
|
|
201
128
|
require_paths:
|
|
202
129
|
- lib
|
|
@@ -204,15 +131,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
204
131
|
requirements:
|
|
205
132
|
- - ">="
|
|
206
133
|
- !ruby/object:Gem::Version
|
|
207
|
-
version:
|
|
134
|
+
version: '3.1'
|
|
208
135
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
209
136
|
requirements:
|
|
210
137
|
- - ">="
|
|
211
138
|
- !ruby/object:Gem::Version
|
|
212
139
|
version: '0'
|
|
213
140
|
requirements: []
|
|
214
|
-
rubygems_version: 3.
|
|
215
|
-
signing_key:
|
|
141
|
+
rubygems_version: 3.3.27
|
|
142
|
+
signing_key:
|
|
216
143
|
specification_version: 4
|
|
217
144
|
summary: Validation library
|
|
218
145
|
test_files: []
|