dry-validation 1.0.0.alpha1 → 1.0.0.alpha2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -1
- data/lib/dry/validation/constants.rb +2 -0
- data/lib/dry/validation/contract.rb +11 -5
- data/lib/dry/validation/result.rb +19 -2
- 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: 288a3f0d9af21271cfeb794d48752ba6bfa93c8e4fa088e8faa9f6eb9a05e083
|
4
|
+
data.tar.gz: 1949525da40fb528c5eda20c610a5c017c260600613ba4fc392f23cd6a84a8d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4884bb2c55f0b987b0aad70bceaedc0d1bc5adc5056bd47e9606e126a9ce9bcb450f5ec7c2035b35572eb4677c4ee0c1525856fe83866b07bf559a75b97a260
|
7
|
+
data.tar.gz: f8f79772a1950752dfa03204269df85d7480c52114c4369d2e895e1edd02b6f02ee3bc03049a2c4ed0994042b104b82dd0e22fcb1c31882b7b0c741d414c8ae1
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
# v1.0.0.alpha2 2019-03-05
|
2
|
+
|
3
|
+
First round of bug fixes. Thanks for testing <3!
|
4
|
+
|
5
|
+
### Fixed
|
6
|
+
|
7
|
+
* Errors with nested messages are correctly built (flash-gordon)
|
8
|
+
* Messages for nested keys are correctly resolved (solnic)
|
9
|
+
* A message for a nested key is resolved when it's defined under `errors.rule.%{key}` too, but a message under nested key will override it (solnic)
|
10
|
+
|
11
|
+
### Changed
|
12
|
+
|
13
|
+
* When a message template is not found a more meaningful error is raised that includes both rule identifier and key path (solnic)
|
14
|
+
|
15
|
+
[Compare v1.0.0.alpha1...v1.0.0.alpha2](https://github.com/dry-rb/dry-validation/compare/v1.0.0.alpha1...v1.0.0.alpha2)
|
16
|
+
|
1
17
|
# v1.0.0.alpha1 2019-03-04
|
2
18
|
|
3
19
|
Complete rewrite on top of `dry-schema`.
|
@@ -26,7 +42,7 @@ Complete rewrite on top of `dry-schema`.
|
|
26
42
|
|
27
43
|
### Changed
|
28
44
|
|
29
|
-
* [internal]
|
45
|
+
* [internal] dry-logic was pinned to `~> 0.4.2` (flash-gordon)
|
30
46
|
|
31
47
|
[Compare v0.12.2...v0.12.3](https://github.com/dry-rb/dry-validation/compare/v0.12.2...v0.12.3)
|
32
48
|
|
@@ -119,13 +119,19 @@ module Dry
|
|
119
119
|
#
|
120
120
|
# @api private
|
121
121
|
def message(key, tokens: EMPTY_HASH, **opts)
|
122
|
-
|
122
|
+
msg_opts = opts.merge(tokens)
|
123
|
+
rule_path = Array(opts.fetch(:rule)).flatten
|
123
124
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
125
|
+
template = messages[key, msg_opts.merge(rule: rule_path.join(DOT))]
|
126
|
+
template ||= messages[key, msg_opts.merge(rule: rule_path.last)]
|
127
|
+
|
128
|
+
unless template
|
129
|
+
raise MissingMessageError, <<~STR
|
130
|
+
Message template for #{key.inspect} under #{rule_path.join(DOT).inspect} was not found
|
131
|
+
STR
|
128
132
|
end
|
133
|
+
|
134
|
+
template.(template.data(tokens))
|
129
135
|
end
|
130
136
|
end
|
131
137
|
end
|
@@ -74,7 +74,7 @@ module Dry
|
|
74
74
|
#
|
75
75
|
# @api private
|
76
76
|
def add_error(key, message)
|
77
|
-
(errors
|
77
|
+
add_to(errors, key, message)
|
78
78
|
self
|
79
79
|
end
|
80
80
|
|
@@ -86,7 +86,13 @@ module Dry
|
|
86
86
|
#
|
87
87
|
# @api public
|
88
88
|
def [](key)
|
89
|
-
|
89
|
+
if values.key?(key)
|
90
|
+
values[key]
|
91
|
+
elsif storage.key?(key)
|
92
|
+
storage[key]
|
93
|
+
else
|
94
|
+
nil
|
95
|
+
end
|
90
96
|
end
|
91
97
|
|
92
98
|
# Store value under specified key
|
@@ -142,6 +148,17 @@ module Dry
|
|
142
148
|
def storage
|
143
149
|
@storage ||= EMPTY_HASH.dup
|
144
150
|
end
|
151
|
+
|
152
|
+
# @api private
|
153
|
+
def add_to(hash, path, value)
|
154
|
+
if path.is_a?(Hash)
|
155
|
+
key = path.keys[0]
|
156
|
+
messages = (hash[key] ||= EMPTY_HASH.dup)
|
157
|
+
add_to(messages, path[key], value)
|
158
|
+
else
|
159
|
+
(hash[path] ||= EMPTY_ARRAY.dup) << value
|
160
|
+
end
|
161
|
+
end
|
145
162
|
end
|
146
163
|
end
|
147
164
|
end
|
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.0.0.
|
4
|
+
version: 1.0.0.alpha2
|
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-03-
|
11
|
+
date: 2019-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|