dry-validation 1.5.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -1
- data/lib/dry/validation/evaluator.rb +2 -2
- data/lib/dry/validation/extensions/hints.rb +1 -3
- data/lib/dry/validation/macros.rb +1 -1
- data/lib/dry/validation/message_set.rb +1 -1
- data/lib/dry/validation/messages/resolver.rb +13 -1
- data/lib/dry/validation/values.rb +4 -1
- 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: 2deba7f8bd2d4ad011e0f4be2aa20d4f20d219d85d0eeec23d3b3e0b12c0bcf4
|
4
|
+
data.tar.gz: 12f9500062c0239d19f6bf32450db22065a9caa3062e4cb71d79a9370c3229ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be6cf6d5dfce8ebec88743b7661eaf4d3cc1294cea249b87e7c02fd00b36013a033fe5feab1ccdb3e6e6020873435fbfc5bf6ee41b5f76836358973f5074843e
|
7
|
+
data.tar.gz: 77f87593b028dfa608f22835413a73fcbd7c2585e9a98c95f20a158df47fc5ca3f46a0357188f5bd1fc37140de7b57b833ae969aabe55bbdf71628f7db6f645e
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,18 @@
|
|
1
1
|
## unreleased
|
2
2
|
|
3
3
|
|
4
|
+
### Fixed
|
5
|
+
|
6
|
+
- dry-monads no longer required for the `:hints` extension (@schokomarie)
|
7
|
+
- Using `full: true` option works as expected with custom rule messages (issue #618 fixed via #651) (@sirfilip)
|
8
|
+
- Using `locale: ...` option works as expected with hints (issue #589 fixed via #652) (@sirfilip)
|
9
|
+
|
10
|
+
|
11
|
+
[Compare v1.5.0...master](https://github.com/dry-rb/dry-validation/compare/v1.5.0...master)
|
12
|
+
|
13
|
+
## 1.5.0 2020-03-11
|
14
|
+
|
15
|
+
|
4
16
|
### Added
|
5
17
|
|
6
18
|
- `schema_error?` rule helper (@waiting-for-dev)
|
@@ -11,7 +23,7 @@
|
|
11
23
|
- dry-schema dependency was bumped to `~> 1.5` (@solnic)
|
12
24
|
- [internal] `KeyMap` patches have been removed since dry-schema now provides required functionality (@solnic)
|
13
25
|
|
14
|
-
[Compare v1.4.2...
|
26
|
+
[Compare v1.4.2...v1.5.0](https://github.com/dry-rb/dry-validation/compare/v1.4.2...v1.5.0)
|
15
27
|
|
16
28
|
## 1.4.2 2020-01-18
|
17
29
|
|
@@ -146,7 +146,7 @@ module Dry
|
|
146
146
|
#
|
147
147
|
# @return [Object]
|
148
148
|
#
|
149
|
-
# @public
|
149
|
+
# @api public
|
150
150
|
def value
|
151
151
|
values[key_name]
|
152
152
|
end
|
@@ -169,7 +169,7 @@ module Dry
|
|
169
169
|
|
170
170
|
# Check if there are any errors on the schema under the provided path
|
171
171
|
#
|
172
|
-
# @param [Symbol, String, Array] A Path-compatible spec
|
172
|
+
# @param path [Symbol, String, Array] A Path-compatible spec
|
173
173
|
#
|
174
174
|
# @return [Boolean]
|
175
175
|
#
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "dry/monads/result"
|
4
|
-
|
5
3
|
module Dry
|
6
4
|
module Validation
|
7
5
|
# Hints extension
|
@@ -46,7 +44,7 @@ module Dry
|
|
46
44
|
#
|
47
45
|
# @api public
|
48
46
|
def messages(new_options = EMPTY_HASH)
|
49
|
-
errors.with(hints.to_a, options.merge(**new_options))
|
47
|
+
errors.with(hints(new_options).to_a, options.merge(**new_options))
|
50
48
|
end
|
51
49
|
|
52
50
|
# Return hint messages
|
@@ -85,7 +85,7 @@ module Dry
|
|
85
85
|
# @api private
|
86
86
|
def freeze
|
87
87
|
source_messages.select { |err| err.respond_to?(:evaluate) }.each do |err|
|
88
|
-
idx = source_messages.index(err)
|
88
|
+
idx = messages.index(err) || source_messages.index(err)
|
89
89
|
msg = err.evaluate(locale: locale, full: options[:full])
|
90
90
|
messages[idx] = msg
|
91
91
|
end
|
@@ -33,7 +33,7 @@ module Dry
|
|
33
33
|
when Symbol
|
34
34
|
Message[->(**opts) { message(message, path: path, tokens: tokens, **opts) }, path, meta]
|
35
35
|
when String
|
36
|
-
Message[message, path, meta]
|
36
|
+
Message[->(**opts) { [message_text(message, path, **opts), meta] }, path, meta]
|
37
37
|
when Hash
|
38
38
|
meta = message.dup
|
39
39
|
text = meta.delete(:text) { |key|
|
@@ -51,6 +51,18 @@ module Dry
|
|
51
51
|
end
|
52
52
|
alias_method :[], :call
|
53
53
|
|
54
|
+
# Resolve a message
|
55
|
+
#
|
56
|
+
# @return String
|
57
|
+
#
|
58
|
+
# @api public
|
59
|
+
def message_text(message, path, locale: nil, full: false, **opts)
|
60
|
+
keys = path.to_a.compact
|
61
|
+
msg_opts = EMPTY_HASH.merge(path: keys, locale: locale || messages.default_locale)
|
62
|
+
|
63
|
+
full ? "#{messages.rule(keys.last, msg_opts) || keys.last} #{message}" : message
|
64
|
+
end
|
65
|
+
|
54
66
|
# Resolve a message
|
55
67
|
#
|
56
68
|
# @return [String]
|
@@ -35,7 +35,10 @@ module Dry
|
|
35
35
|
# key.failure('must be > 18') if values[:age] <= 18
|
36
36
|
# end
|
37
37
|
#
|
38
|
-
# @param [Symbol]
|
38
|
+
# @param args [Symbol, String, Hash, Array<Symbol>] If given as a single
|
39
|
+
# Symbol, String, Array or Hash, build a key array using
|
40
|
+
# {Dry::Schema::Path} digging for data. If given as positional
|
41
|
+
# arguments, use these with Hash#dig on the data directly.
|
39
42
|
#
|
40
43
|
# @return [Object]
|
41
44
|
#
|
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.5.
|
4
|
+
version: 1.5.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: 2020-
|
11
|
+
date: 2020-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|