dry-validation 1.2.0 → 1.2.1
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 +11 -0
- data/lib/dry/validation/constants.rb +1 -0
- data/lib/dry/validation/contract.rb +3 -1
- data/lib/dry/validation/contract/class_interface.rb +1 -1
- data/lib/dry/validation/result.rb +16 -0
- data/lib/dry/validation/rule.rb +7 -5
- data/lib/dry/validation/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c16031447235e4a737bb2fd2c406017b6bc082415ade63f8fe4d364c9b720be1
|
4
|
+
data.tar.gz: 10d0e6aaddeb0df982894c95e305eef3c6f05bbc3ac2cf229b9926f0acfe791f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0363485af3db4081d46ea89ad5f1918c557d2b38b9ec357640bb1feb1eec3c6fbc4cd5a8ff5650f830bcf3440abe7d4f7e570377fad8fc803fd0ccc9d91ce49
|
7
|
+
data.tar.gz: 7a89b67fe79eb7a8e3a63b939b33af67a13b89ad005d2d334c3d3db626bd960e19a957b25508239358bcb634deaeb116e91fab1878b393c3b106f6a028f96a8d
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
# v1.2.1 2019-07-16
|
2
|
+
|
3
|
+
### Fixed
|
4
|
+
|
5
|
+
* Defining an abstract contract class that has no schema no longer crashes (issue #565) (@solnic)
|
6
|
+
* Fixed an issue where `Rule#each` would crash when the value is not an array (issue #567) (@solnic)
|
7
|
+
* Fixed an issue where guarding a rule would crash when keys are missing in the input (issue #569) (@solnic)
|
8
|
+
* Added missing "pathname" require (issue #570) (@solnic)
|
9
|
+
|
10
|
+
[Compare v1.2.0...v1.2.1](https://github.com/dry-rb/dry-validation/compare/v1.2.0...v1.2.1)
|
11
|
+
|
1
12
|
# v1.2.0 2019-07-08
|
2
13
|
|
3
14
|
### Added
|
@@ -128,7 +128,9 @@ module Dry
|
|
128
128
|
|
129
129
|
return false unless result.error?(curr_path)
|
130
130
|
|
131
|
-
result.errors.any? { |err|
|
131
|
+
result.errors.any? { |err|
|
132
|
+
(other = Schema::Path[err.path]).same_root?(curr_path) && other == curr_path
|
133
|
+
}
|
132
134
|
}
|
133
135
|
end
|
134
136
|
|
@@ -106,6 +106,22 @@ module Dry
|
|
106
106
|
schema_result.error?(key)
|
107
107
|
end
|
108
108
|
|
109
|
+
# Check if there's any error for the provided key
|
110
|
+
#
|
111
|
+
# This does not consider errors from the nested values
|
112
|
+
#
|
113
|
+
# @api private
|
114
|
+
def base_error?(key)
|
115
|
+
schema_result.errors.any? { |error|
|
116
|
+
key_path = Schema::Path[key]
|
117
|
+
err_path = Schema::Path[error.path]
|
118
|
+
|
119
|
+
return false unless key_path.same_root?(err_path)
|
120
|
+
|
121
|
+
key_path == err_path
|
122
|
+
}
|
123
|
+
end
|
124
|
+
|
109
125
|
# Add a new error for the provided key
|
110
126
|
#
|
111
127
|
# @api private
|
data/lib/dry/validation/rule.rb
CHANGED
@@ -82,14 +82,16 @@ module Dry
|
|
82
82
|
@keys = []
|
83
83
|
|
84
84
|
@block = proc do
|
85
|
-
(
|
86
|
-
|
85
|
+
unless result.base_error?(root) || !values.key?(root)
|
86
|
+
values[root].each_with_index do |_, idx|
|
87
|
+
path = [*Schema::Path[root].to_a, idx]
|
87
88
|
|
88
|
-
|
89
|
+
next if result.error?(path)
|
89
90
|
|
90
|
-
|
91
|
+
evaluator = with(macros: macros, keys: [path], &block)
|
91
92
|
|
92
|
-
|
93
|
+
failures.concat(evaluator.failures)
|
94
|
+
end
|
93
95
|
end
|
94
96
|
end
|
95
97
|
|
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.2.
|
4
|
+
version: 1.2.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: 2019-07-
|
11
|
+
date: 2019-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|