dry-schema 1.5.1 → 1.5.3

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: c56536db764858bb0d594688d581e4f38fd46f949f75829c20a63d67902f3704
4
- data.tar.gz: f99af785ccdee69c8cc5d4398b4802612c2b3456e4d472a25d591d593ac9d2bb
3
+ metadata.gz: ed1f0c97144ee071608d437d3d0f17b8031e942bc53335dddd52f9701c51c1c0
4
+ data.tar.gz: c6d24ab22475c7794c999a7e04b3106451356080014ef4c087a4d1458bc21783
5
5
  SHA512:
6
- metadata.gz: d6f538d54f0ab58595f14e94340e1cb2a3da45a5a4909e8aa5e3bb1a6d68fcd5992debf4d6a8c7909fb25166c11160d970dfb06ac4266e87869117ca984574b1
7
- data.tar.gz: 3a26179c03e7f4fccce53ae19c6d9133af913407ba64d05bf28a1b173fbdc5e922176edf94c48842829c5b52eda16f5589aa1b98b2848b3094e3713fc2844716
6
+ metadata.gz: 91e0a095b534dc935c372830e8cfc5ae55fd854994b7641b90e59efd11e739b81296b575a486836982b99804349c3d2cd8d539ea207101b43675db95b0a0557a
7
+ data.tar.gz: c4e691dfe79c69a6d71e4046d9d81d23b8da16b4861b313fd66977d3d0be2a337bf7e80e6aef23c85561217608b2d589ce098c4c9626a177106eb45158e079b8
@@ -1,3 +1,29 @@
1
+ ## 1.5.3 2020-08-21
2
+
3
+
4
+ ### Fixed
5
+
6
+ - Key validator works correctly with an array with maybe hash as its member (issue #308 fixed via #309) (@tadeusz-niemiec)
7
+
8
+ ### Changed
9
+
10
+ - [info extension] small performance improvement in the set visitor (see #305 for more details) (@esparta)
11
+
12
+ [Compare v1.5.2...v1.5.3](https://github.com/dry-rb/dry-schema/compare/v1.5.2...v1.5.3)
13
+
14
+ ## 1.5.2 2020-06-26
15
+
16
+
17
+ ### Fixed
18
+
19
+ - `Result#{success?,failure?}` work as expected when there are only key validation failures (issue #297 fixed via #298) (@adamransom)
20
+
21
+ ### Changed
22
+
23
+ - Using `full` option no longer adds a space between the name of a key and the message in case of languages that have no spaces between words (ie Japanese) (issue #161 closed via #292 by @tadeusz-niemiec)
24
+
25
+ [Compare v1.5.1...v1.5.2](https://github.com/dry-rb/dry-schema/compare/v1.5.1...v1.5.2)
26
+
1
27
  ## 1.5.1 2020-05-21
2
28
 
3
29
 
@@ -50,7 +50,7 @@ module Dry
50
50
  def visit_set(node, opts = EMPTY_HASH)
51
51
  target = (key = opts[:key]) ? self.class.new : self
52
52
 
53
- node.map { |child| target.visit(child, opts) }
53
+ node.each { |child| target.visit(child, opts) }
54
54
 
55
55
  return unless key
56
56
 
@@ -28,7 +28,7 @@ module Dry
28
28
  if path[INDEX_REGEX]
29
29
  key = path.gsub(INDEX_REGEX, BRACKETS)
30
30
 
31
- unless key_paths.include?(key)
31
+ if key_paths.none? { |key_path| key_path.include?(key) }
32
32
  arr = path.gsub(INDEX_REGEX) { |m| ".#{m[1]}" }
33
33
  arr.split(DOT).map { |s| DIGIT_REGEX.match?(s) ? s.to_i : s.to_sym }
34
34
  end
@@ -29,6 +29,14 @@ module Dry
29
29
 
30
30
  EMPTY_OPTS = VisitorOpts.new
31
31
  EMPTY_MESSAGE_SET = MessageSet.new(EMPTY_ARRAY).freeze
32
+ FULL_MESSAGE_WHITESPACE = Hash.new(' ').merge(
33
+ ja: '',
34
+ zh: '',
35
+ bn: '',
36
+ th: '',
37
+ lo: '',
38
+ my: '',
39
+ )
32
40
 
33
41
  param :messages
34
42
 
@@ -203,12 +211,12 @@ module Dry
203
211
  return text if !text || !full
204
212
 
205
213
  rule = options[:path]
206
- "#{messages.rule(rule, options) || rule} #{text}"
214
+ [messages.rule(rule, options) || rule, text].join(FULL_MESSAGE_WHITESPACE[template.options[:locale]])
207
215
  end
208
216
 
209
217
  # @api private
210
218
  def message_tokens(args)
211
- args.each_with_object({}) do |arg, hash|
219
+ tokens = args.each_with_object({}) do |arg, hash|
212
220
  case arg[1]
213
221
  when Array
214
222
  hash[arg[0]] = arg[1].join(LIST_SEPARATOR)
@@ -219,6 +227,14 @@ module Dry
219
227
  hash[arg[0]] = arg[1]
220
228
  end
221
229
  end
230
+ args.any? { |e| e.first == :size } ? append_mapped_size_tokens(tokens) : tokens
231
+ end
232
+
233
+ # @api private
234
+ def append_mapped_size_tokens(tokens)
235
+ # this is a temporary fix for the inconsistency in the "size" errors arguments
236
+ mapped_hash = tokens.each_with_object({}) { |(k, v), h| h[k.to_s.gsub("size", "num").to_sym] = v }
237
+ tokens.merge(mapped_hash)
222
238
  end
223
239
  end
224
240
  end
@@ -121,7 +121,7 @@ module Dry
121
121
  #
122
122
  # @api public
123
123
  def success?
124
- results.empty?
124
+ result_ast.empty?
125
125
  end
126
126
 
127
127
  # Check if the result is not successful
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Dry
4
4
  module Schema
5
- VERSION = "1.5.1"
5
+ VERSION = "1.5.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.5.1
4
+ version: 1.5.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: 2020-05-21 00:00:00.000000000 Z
11
+ date: 2020-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby