dry-validation 0.12.3 → 0.13.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/.travis.yml +16 -12
- data/CHANGELOG.md +192 -187
- data/Gemfile +1 -2
- data/dry-validation.gemspec +2 -2
- data/lib/dry/validation/predicates.rb +19 -0
- data/lib/dry/validation/schema/class_interface.rb +2 -1
- data/lib/dry/validation/version.rb +1 -1
- metadata +19 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b85a523c346bfbd6ec5acfb6fa1809a876cf4563a7fd88a39f21a81b40f5c0db
|
|
4
|
+
data.tar.gz: 6154b45e7e5f41aed6f5724b3ad11fa455a7e6f3045895ddb2db0cd1f3d04cdf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 66080c0d183336412d06c5355fb2f277ae0766fdc8d110deb46176385f89f0a519d91a5365b6f5bc4a241d064861cafacbca3eb72409d8d4c1bf1613c7faa3c9
|
|
7
|
+
data.tar.gz: 69bc582befbc000f3472eb382d475b847fd6e8144f980f8ce84823f3d084afa6db892a8303d810a66ce943b68e7c05ea9827ecedff4b7db0b48050463cfa30b0
|
data/.travis.yml
CHANGED
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
language: ruby
|
|
2
|
-
dist: trusty
|
|
3
|
-
sudo: required
|
|
4
2
|
cache: bundler
|
|
3
|
+
sudo: false
|
|
5
4
|
bundler_args: --without benchmarks tools
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
before_install: gem update --system
|
|
6
|
+
before_script:
|
|
7
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
|
8
|
+
- chmod +x ./cc-test-reporter
|
|
9
|
+
- ./cc-test-reporter before-build
|
|
10
|
+
after_script:
|
|
11
|
+
- "[ -d coverage ] && ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT"
|
|
8
12
|
script:
|
|
9
13
|
- bundle exec rake
|
|
10
14
|
rvm:
|
|
11
|
-
- 2.
|
|
12
|
-
- 2.3
|
|
13
|
-
- 2.4.
|
|
14
|
-
-
|
|
15
|
+
- 2.6.0
|
|
16
|
+
- 2.5.3
|
|
17
|
+
- 2.4.5
|
|
18
|
+
- 2.3.8
|
|
19
|
+
- jruby-9.2.5.0
|
|
15
20
|
env:
|
|
16
21
|
global:
|
|
17
22
|
- COVERAGE=true
|
|
18
|
-
- JRUBY_OPTS='--dev -J-Xmx1024M'
|
|
19
23
|
notifications:
|
|
20
24
|
email: false
|
|
21
25
|
webhooks:
|
|
22
26
|
urls:
|
|
23
27
|
- https://webhooks.gitter.im/e/19098b4253a72c9796db
|
|
24
|
-
on_success: change
|
|
25
|
-
on_failure: always
|
|
26
|
-
on_start: false
|
|
28
|
+
on_success: change # options: [always|never|change] default: always
|
|
29
|
+
on_failure: always # options: [always|never|change] default: always
|
|
30
|
+
on_start: false # default: false
|
data/CHANGELOG.md
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
# v0.
|
|
1
|
+
# v0.13.0 2019-01-29
|
|
2
2
|
|
|
3
3
|
### Changed
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
- `dry-logic` was bumped to `~> 0.5` (solnic)
|
|
6
|
+
- `dry-types` was bumped to `~> 0.14` (solnic)
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
### Fixed
|
|
9
|
+
|
|
10
|
+
- Warning about method redefined (amatsuda)
|
|
11
|
+
|
|
12
|
+
[Compare v0.12.2...v0.13.0](https://github.com/dry-rb/dry-validation/compare/v0.12.2...v0.13.0)
|
|
8
13
|
|
|
9
14
|
# v0.12.2 2018-08-29
|
|
10
15
|
|
|
11
16
|
### Fixed
|
|
12
17
|
|
|
13
|
-
|
|
18
|
+
- Use correct key names for rule messages when using i18n (jozzi05)
|
|
14
19
|
|
|
15
20
|
[Compare v0.12.1...v0.12.2](https://github.com/dry-rb/dry-validation/compare/v0.12.1...v0.12.2)
|
|
16
21
|
|
|
@@ -18,7 +23,7 @@
|
|
|
18
23
|
|
|
19
24
|
### Fixed
|
|
20
25
|
|
|
21
|
-
|
|
26
|
+
- [internal] fixed deprecation warnings (flash-gordon)
|
|
22
27
|
|
|
23
28
|
[Compare v0.12.0...v0.12.1](https://github.com/dry-rb/dry-validation/compare/v0.12.0...v0.12.1)
|
|
24
29
|
|
|
@@ -26,8 +31,8 @@
|
|
|
26
31
|
|
|
27
32
|
### Changed
|
|
28
33
|
|
|
29
|
-
|
|
30
|
-
|
|
34
|
+
- Code updated to work with `dry-types` 0.13.1 and `dry-struct` 0.5.0, these are now minimal supported versions (flash-gordon)
|
|
35
|
+
- [BREAKING] `Form` was renamed to `Params` to be consistent with the latest changes from `dry-types`. You can `require 'dry/validation/compat/form'` to use the previous names but it will be removed in the next version (flash-gordon)
|
|
31
36
|
|
|
32
37
|
[Compare v0.11.1...v0.12.0](https://github.com/dry-rb/dry-validation/compare/v0.11.1...v0.12.0)
|
|
33
38
|
|
|
@@ -35,8 +40,8 @@
|
|
|
35
40
|
|
|
36
41
|
### Changed
|
|
37
42
|
|
|
38
|
-
|
|
39
|
-
|
|
43
|
+
- `Result#to_either` was renamed to `#to_monad`, the previous name is kept for backward compatibility (flash-gordon)
|
|
44
|
+
- [internal] fix warnings from dry-types v0.12.0
|
|
40
45
|
|
|
41
46
|
[Compare v0.11.0...v0.11.1](https://github.com/dry-rb/dry-validation/compare/v0.11.0...v0.11.1)
|
|
42
47
|
|
|
@@ -44,7 +49,7 @@
|
|
|
44
49
|
|
|
45
50
|
### Changed
|
|
46
51
|
|
|
47
|
-
|
|
52
|
+
- [internal] input processor compilers have been updated to work with new dry-types' AST (GustavoCaso)
|
|
48
53
|
|
|
49
54
|
[Compare v0.10.7...v0.11.0](https://github.com/dry-rb/dry-validation/compare/v0.10.7...v0.11.0)
|
|
50
55
|
|
|
@@ -52,8 +57,8 @@
|
|
|
52
57
|
|
|
53
58
|
### Fixed
|
|
54
59
|
|
|
55
|
-
|
|
56
|
-
|
|
60
|
+
- `validate` can now be defined multiple times for the same key (kimquy)
|
|
61
|
+
- Re-using rules between schemas no longer mutates original rule set (pabloh)
|
|
57
62
|
|
|
58
63
|
[Compare v0.10.6...v0.10.7](https://github.com/dry-rb/dry-validation/compare/v0.10.6...v0.10.7)
|
|
59
64
|
|
|
@@ -61,7 +66,7 @@
|
|
|
61
66
|
|
|
62
67
|
### Fixed
|
|
63
68
|
|
|
64
|
-
|
|
69
|
+
- Fixes issue with wrong localized error messages when namespaced messages are used (kbredemeier)
|
|
65
70
|
|
|
66
71
|
[Compare v0.10.5...v0.10.6](https://github.com/dry-rb/dry-validation/compare/v0.10.5...v0.10.6)
|
|
67
72
|
|
|
@@ -69,7 +74,7 @@
|
|
|
69
74
|
|
|
70
75
|
### Fixed
|
|
71
76
|
|
|
72
|
-
|
|
77
|
+
- Warnings under MRI 2.4.0 are gone (koic)
|
|
73
78
|
|
|
74
79
|
[Compare v0.10.4...v0.10.5](https://github.com/dry-rb/dry-validation/compare/v0.10.4...v0.10.5)
|
|
75
80
|
|
|
@@ -77,12 +82,12 @@
|
|
|
77
82
|
|
|
78
83
|
### Fixed
|
|
79
84
|
|
|
80
|
-
|
|
81
|
-
|
|
85
|
+
- Updated to dry-core >= 0.2.1 (ruby warnings are gone) (flash-gordon)
|
|
86
|
+
- `format?` predicate is excluded from hints (solnic)
|
|
82
87
|
|
|
83
88
|
### Changed
|
|
84
89
|
|
|
85
|
-
|
|
90
|
+
- `version` file is now required by default (georgemillo)
|
|
86
91
|
|
|
87
92
|
[Compare v0.10.3...v0.10.4](https://github.com/dry-rb/dry-validation/compare/v0.10.3...v0.10.4)
|
|
88
93
|
|
|
@@ -90,7 +95,7 @@
|
|
|
90
95
|
|
|
91
96
|
### Fixed
|
|
92
97
|
|
|
93
|
-
|
|
98
|
+
- Custom predicates work correctly with `each` macro (solnic)
|
|
94
99
|
|
|
95
100
|
[Compare v0.10.2...v0.10.3](https://github.com/dry-rb/dry-validation/compare/v0.10.2...v0.10.3)
|
|
96
101
|
|
|
@@ -98,7 +103,7 @@
|
|
|
98
103
|
|
|
99
104
|
### Fixed
|
|
100
105
|
|
|
101
|
-
|
|
106
|
+
- Constrained types + hints work again (solnic)
|
|
102
107
|
|
|
103
108
|
[Compare v0.10.1...v0.10.2](https://github.com/dry-rb/dry-validation/compare/v0.10.1...v0.10.2)
|
|
104
109
|
|
|
@@ -106,7 +111,7 @@
|
|
|
106
111
|
|
|
107
112
|
### Fixed
|
|
108
113
|
|
|
109
|
-
|
|
114
|
+
- Remove obsolete require of `dry/struct` which is now an optional extension (flash-gordon)
|
|
110
115
|
|
|
111
116
|
[Compare v0.10.0...v0.10.1](https://github.com/dry-rb/dry-validation/compare/v0.10.0...v0.10.1)
|
|
112
117
|
|
|
@@ -114,32 +119,32 @@
|
|
|
114
119
|
|
|
115
120
|
### Added
|
|
116
121
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
- Support for `validate` DSL which accepts an arbitratry validation block that gets executed in the context of a schema object and is treated as a custom predicate (solnic)
|
|
123
|
+
- Support for `or` error messages ie "must be a string or must be an integer" (solnic)
|
|
124
|
+
- Support for retrieving error messages exclusively via `schema.(input).errors` (solnic)
|
|
125
|
+
- Support for retrieving hint messages exclusively via `schema.(input).hints` (solnic)
|
|
126
|
+
- Support for opt-in extensions loaded via `Dry::Validation.load_extensions(:my_ext)` (flash-gordon)
|
|
127
|
+
- Add `:monads` extension which transforms a result instance to `Either` monad, `schema.(input).to_either` (flash-gordon)
|
|
128
|
+
- Add `dry-struct` integration via an extension activated by `Dry::Validation.load_extensions(:struct)` (flash-gordon)
|
|
124
129
|
|
|
125
130
|
### Fixed
|
|
126
131
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
132
|
+
- Input rules (defined via `input` macro) are now lazy-initialized which makes it work with predicates defined on the schema object (solnic)
|
|
133
|
+
- Hints are properly generated based on argument type in cases like `size?`, where the message should be different for strings (uses "length") or other types (uses "size") (solnic)
|
|
134
|
+
- Defining nested keys without `schema` blocks results in `ArgumentError` (solnic)
|
|
130
135
|
|
|
131
136
|
### Changed
|
|
132
137
|
|
|
133
|
-
|
|
134
|
-
|
|
138
|
+
- [BREAKING] `when` macro no longer supports multiple disconnected rules in its block, whatever the block returns will be used for the implication (solnic)
|
|
139
|
+
- [BREAKING] `rule(some_name: %i(some keys))` will _always_ use `:some_name` as the key for failure messages (solnic)
|
|
135
140
|
|
|
136
141
|
### Internal
|
|
137
142
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
+
- ~2 x performance boost (solnic)
|
|
144
|
+
- Rule AST was updated to latest dry-logic (solnic)
|
|
145
|
+
- `MessageCompiler` was drastically simplified based on the new result AST from dry-logic (solnic)
|
|
146
|
+
- `HintCompiler` is gone as hints are now part of the result AST (solnic)
|
|
147
|
+
- `maybe` macro creates an implication instead of a disjunction (`not(none?).then(*your-predicates)`) (solnic)
|
|
143
148
|
|
|
144
149
|
[Compare v0.9.5...v0.10.0](https://github.com/dry-rb/dry-validation/compare/v0.9.5...v0.10.0)
|
|
145
150
|
|
|
@@ -147,8 +152,8 @@
|
|
|
147
152
|
|
|
148
153
|
### Fixed
|
|
149
154
|
|
|
150
|
-
|
|
151
|
-
|
|
155
|
+
- Infering multiple predicates with options works as expected ie `value(:str?, min_size?: 3, max_size?: 6)` (solnic)
|
|
156
|
+
- Default `locale` configured in `I18n` is now respected by the messages compiler (agustin + cavi21)
|
|
152
157
|
|
|
153
158
|
[Compare v0.9.4...v0.9.5](https://github.com/dry-rb/dry-validation/compare/v0.9.4...v0.9.5)
|
|
154
159
|
|
|
@@ -156,7 +161,7 @@
|
|
|
156
161
|
|
|
157
162
|
### Fixed
|
|
158
163
|
|
|
159
|
-
|
|
164
|
+
- Error messages for sibling deeply nested schemas are nested correctly (timriley)
|
|
160
165
|
|
|
161
166
|
[Compare v0.9.3...v0.9.4](https://github.com/dry-rb/dry-validation/compare/v0.9.3...v0.9.4)
|
|
162
167
|
|
|
@@ -164,17 +169,17 @@
|
|
|
164
169
|
|
|
165
170
|
### Added
|
|
166
171
|
|
|
167
|
-
|
|
168
|
-
|
|
172
|
+
- Support for range arg in error messages for `excluded_from?` and `included_in?` (mrbongiolo)
|
|
173
|
+
- `Result#message_set` returns raw message set object (solnic)
|
|
169
174
|
|
|
170
175
|
### Fixed
|
|
171
176
|
|
|
172
|
-
|
|
173
|
-
|
|
177
|
+
- Error messages for high-level rules in nested schemas are nested correctly (solnic)
|
|
178
|
+
- Dumping error messages works with high-level rules relying on the same value (solnic)
|
|
174
179
|
|
|
175
180
|
### Changed
|
|
176
181
|
|
|
177
|
-
|
|
182
|
+
- `#messages` is no longer memoized (solnic)
|
|
178
183
|
|
|
179
184
|
[Compare v0.9.2...v0.9.3](https://github.com/dry-rb/dry-validation/compare/v0.9.2...v0.9.3)
|
|
180
185
|
|
|
@@ -182,8 +187,8 @@
|
|
|
182
187
|
|
|
183
188
|
### Fixed
|
|
184
189
|
|
|
185
|
-
|
|
186
|
-
|
|
190
|
+
- Constrained types now work with `each` macro (solnic)
|
|
191
|
+
- Array coercion without member type works now ie `required(:arr).maybe(:array?)` (solnic)
|
|
187
192
|
|
|
188
193
|
[Compare v0.9.1...v0.9.2](https://github.com/dry-rb/dry-validation/compare/v0.9.1...v0.9.2)
|
|
189
194
|
|
|
@@ -191,7 +196,7 @@
|
|
|
191
196
|
|
|
192
197
|
### Fixed
|
|
193
198
|
|
|
194
|
-
|
|
199
|
+
- `I18n` backend is no longer required and set by default (solnic)
|
|
195
200
|
|
|
196
201
|
[Compare v0.9.0...v0.9.1](https://github.com/dry-rb/dry-validation/compare/v0.9.0...v0.9.1)
|
|
197
202
|
|
|
@@ -199,36 +204,36 @@
|
|
|
199
204
|
|
|
200
205
|
### Added
|
|
201
206
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
207
|
+
- Support for defining maybe-schemas via `maybe { schema { .. } }` (solnic)
|
|
208
|
+
- Support for interpolation of custom failure messages for custom rules (solnic)
|
|
209
|
+
- Support for defining a base schema **class** with config and rules (solnic)
|
|
210
|
+
- Support for more than 1 predicate in `input` macro (solnic)
|
|
211
|
+
- Class-level `define!` API for defining rules on a class (solnic)
|
|
212
|
+
- `:i18n` messages support merging from other paths via `messages_file` setting (solnic)
|
|
213
|
+
- Support for message token transformations in custom predicates (fran-worley)
|
|
214
|
+
- [EXPERIMENTAL] Ability to compose predicates that accept dynamic args provided by the schema (solnic)
|
|
210
215
|
|
|
211
216
|
### Changed
|
|
212
217
|
|
|
213
|
-
|
|
218
|
+
- Tokens for `size?` were renamed `left` => `size_left` and `right` => `size_right` (fran-worley)
|
|
214
219
|
|
|
215
220
|
### Fixed
|
|
216
221
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
222
|
+
- Duped key names in nested schemas no longer result in invalid error messages structure (solnic)
|
|
223
|
+
- Error message structure for deeply nested each/schema rules (solnic)
|
|
224
|
+
- Values from `option` are passed down to nested schemas when using `Schema#with` (solnic)
|
|
225
|
+
- Hints now work with array elements too (solnic)
|
|
226
|
+
- Hints for elements are no longer provided for an array when the value is not an array (solnic)
|
|
227
|
+
- `input` macro no longer messes up error messages for nested structures (solnic)
|
|
223
228
|
|
|
224
229
|
### Internal
|
|
225
230
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
231
|
+
- Compiling messages is now ~5% faster (solnic + splattael)
|
|
232
|
+
- Refactored Error and Hint compilers (solnic)
|
|
233
|
+
- Refactored Schema to use an internal executor objects with steps (solnic)
|
|
234
|
+
- Extracted root-rule into a separate validation step (solnic)
|
|
235
|
+
- Added `MessageSet` that result objects now use (in 1.0.0 it'll be exposed via public API) (solnic)
|
|
236
|
+
- We can now distinguish error messages from validation hints via `Message` and `Hint` objects (solnic)
|
|
232
237
|
|
|
233
238
|
[Compare v0.8.0...v0.9.0](https://github.com/dry-rb/dry-validation/compare/v0.8.0...v0.9.0)
|
|
234
239
|
|
|
@@ -236,57 +241,57 @@
|
|
|
236
241
|
|
|
237
242
|
### Added
|
|
238
243
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
244
|
+
- Explicit interface for type specs used to set up coercions, ie `required(:age, :int)` (solnic)
|
|
245
|
+
- Support new dry-logic predicates: `:excluded_from?`, `:excludes?`, `:included_in?`, `:includes?`, `:not_eql?`, `:odd?`, `:even?` (jodosha, fran-worley)
|
|
246
|
+
- Support for blocks in `value`, `filled` and `maybe` macros (solnic)
|
|
247
|
+
- Support for passing a schema to `value|filled|maybe` macros ie `maybe(SomeSchema)` (solnic)
|
|
248
|
+
- Support for `each(SomeSchema)` (solnic)
|
|
249
|
+
- Support for `value|filled|maybe` macros + `each` inside a block ie: `maybe(:filled?) { each(:int?) }` (solnic)
|
|
250
|
+
- Support for dedicated hint messages via `en.errors.#{predicate}.(hint|failure)` look-up paths (solnic)
|
|
251
|
+
- Support for configuring custom DSL extensions via `dsl_extensions` setting on Schema class (solnic)
|
|
252
|
+
- Support for preconfiguring a predicate for the input value ie `value :hash?` used for prerequisite-checks (solnic)
|
|
253
|
+
- Infer coercion from constrained types (solnic)
|
|
254
|
+
- Add value macro (coop)
|
|
255
|
+
- Enable .schema to accept objects that respond to #schema (ttdonovan)
|
|
256
|
+
- Support for schema predicates which don't need any arguments (fran-worley)
|
|
257
|
+
- Error and hint messages have access to all predicate arguments by default (fran-worley+solnic)
|
|
258
|
+
- Invalid predicate name in DSL will raise an error (solnic)
|
|
259
|
+
- Predicate with invalid arity in DSL will raise an error (solnic)
|
|
255
260
|
|
|
256
261
|
### Fixed
|
|
257
262
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
263
|
+
- Support for jRuby 9.1.1.0 (flash-gordon)
|
|
264
|
+
- Fix bug when using predicates with options in each and when (fran-worley)
|
|
265
|
+
- Fix bug when validating custom types (coop)
|
|
266
|
+
- Fix depending on deeply nested values in high-lvl rules (solnic)
|
|
267
|
+
- Fix duplicated error message for lt? when hint was used (solnic)
|
|
268
|
+
- Fix hints for nested schemas (solnic)
|
|
269
|
+
- Fix an issue where rules with same names inside nested schemas have incorrect hints (solnic)
|
|
270
|
+
- Fix a bug where hints were being generated 4 times (solnic)
|
|
271
|
+
- Fix duplicated error messages when message is different than a hint (solnic)
|
|
267
272
|
|
|
268
273
|
### Changed
|
|
269
274
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
275
|
+
- Uses new `:weak` hash constructor from dry-types 0.8.0 which can partially coerce invalid hash (solnic)
|
|
276
|
+
- `key` has been deprecated in favor of `required` (coop)
|
|
277
|
+
- `required` has been deprecated in favor of `filled` (coop)
|
|
278
|
+
- Now relies on dry-logic v0.3.0 and dry-types v0.8.0 (fran-worley)
|
|
279
|
+
- Tring to use illogical predicates with maybe and filled macros now raise InvalidSchemaError (fran-worley)
|
|
280
|
+
- Enable coercion on form.true and form.false (fran-worley)
|
|
281
|
+
- Remove attr (will be extracted to a separate gem) (coop)
|
|
282
|
+
- Deprecate required in favour of filled (coop)
|
|
283
|
+
- Deprecate key in favor of required (coop)
|
|
284
|
+
- Remove nested key syntax (solnic)
|
|
280
285
|
|
|
281
286
|
### Internal
|
|
282
287
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
288
|
+
- ~15% performance boost via various optimizations (solnic)
|
|
289
|
+
- When using explicit type specs building a schema is ~80-85x faster (solnic)
|
|
290
|
+
- No longer uses `Dry::Types::Predicates` as `:type?` predicate was moved to dry-logic (solnic)
|
|
291
|
+
- Integration specs covering predicates with Form and Schema (jodosha)
|
|
292
|
+
- Use latest ruby versions on travis (flash-gordon)
|
|
293
|
+
- Make pry console optional with IRB as a default (flash-gordon)
|
|
294
|
+
- Remove wrapping rules in :set nodes (solnic)
|
|
290
295
|
|
|
291
296
|
[Compare v0.7.4...v0.8.0](https://github.com/dry-rb/dry-validation/compare/v0.7.4...v0.8.0)
|
|
292
297
|
|
|
@@ -294,12 +299,12 @@
|
|
|
294
299
|
|
|
295
300
|
### Added
|
|
296
301
|
|
|
297
|
-
|
|
298
|
-
|
|
302
|
+
- `Schema.JSON` with json-specific coercions (coop)
|
|
303
|
+
- Support for error messages for `odd? and`even?` predicates (fran-worley)
|
|
299
304
|
|
|
300
305
|
### Fixed
|
|
301
306
|
|
|
302
|
-
|
|
307
|
+
- Depending on deeply nested values in high-level rules works now (solnic)
|
|
303
308
|
|
|
304
309
|
[Compare v0.7.3...v0.7.4](https://github.com/dry-rb/dry-validation/compare/v0.7.3...v0.7.4)
|
|
305
310
|
|
|
@@ -307,18 +312,18 @@
|
|
|
307
312
|
|
|
308
313
|
### Added
|
|
309
314
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
315
|
+
- Support for inferring rules from constrained type (coop + solnic)
|
|
316
|
+
- Support for inferring nested schemas from `Dry::Types::Struct` classes (coop)
|
|
317
|
+
- Support for `number?` predicate (solnic)
|
|
313
318
|
|
|
314
319
|
### Fixed
|
|
315
320
|
|
|
316
|
-
|
|
317
|
-
|
|
321
|
+
- Creating a nested schema properly sets full path to nested data structure (solnic)
|
|
322
|
+
- Error message for `empty?` predicate is now correct (jodosha)
|
|
318
323
|
|
|
319
324
|
### Internal
|
|
320
325
|
|
|
321
|
-
|
|
326
|
+
- Switch from `thread_safe` to `concurrent` (joevandyk)
|
|
322
327
|
|
|
323
328
|
[Compare v0.7.2...v0.7.3](https://github.com/dry-rb/dry-validation/compare/v0.7.2...v0.7.3)
|
|
324
329
|
|
|
@@ -326,8 +331,8 @@
|
|
|
326
331
|
|
|
327
332
|
### Added
|
|
328
333
|
|
|
329
|
-
|
|
330
|
-
|
|
334
|
+
- Support for nested schemas inside high-level rules (solnic)
|
|
335
|
+
- `Schema#to_proc` so that you can do `data.each(&schema)` (solnic)
|
|
331
336
|
|
|
332
337
|
[Compare v0.7.1...v0.7.2](https://github.com/dry-rb/dry-validation/compare/v0.7.1...v0.7.2)
|
|
333
338
|
|
|
@@ -335,17 +340,17 @@
|
|
|
335
340
|
|
|
336
341
|
### Added
|
|
337
342
|
|
|
338
|
-
|
|
343
|
+
- You can use `schema` inside `each` macro (solnic)
|
|
339
344
|
|
|
340
345
|
### Fixed
|
|
341
346
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
347
|
+
- `confirmation` macro defines an optional key with maybe value with `_confirmation` suffix (solnic)
|
|
348
|
+
- `each` macro works correctly when its inner rule specify just one key (solnic)
|
|
349
|
+
- error messages for `each` rules where input is equal are now correctly generated (solnic)
|
|
345
350
|
|
|
346
351
|
### Changed
|
|
347
352
|
|
|
348
|
-
|
|
353
|
+
- Now depends on `dry-logic` >= `0.2.1` (solnic)
|
|
349
354
|
|
|
350
355
|
[Compare v0.7.0...v0.7.1](https://github.com/dry-rb/dry-validation/compare/v0.7.0...v0.7.1)
|
|
351
356
|
|
|
@@ -353,41 +358,41 @@
|
|
|
353
358
|
|
|
354
359
|
### Added
|
|
355
360
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
361
|
+
- Support for macros:
|
|
362
|
+
- `required` - when value must be filled
|
|
363
|
+
- `maybe` - when value can be nil (or empty, in case of `Form`)
|
|
364
|
+
- `when` - for composing high-level rule based on predicates applied to a
|
|
360
365
|
validated value
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
366
|
+
- `confirmation` - for confirmation validation
|
|
367
|
+
- Support for `value(:foo).eql?(value(:bar))` syntax in high-level rules (solnic)
|
|
368
|
+
- New DSL for defining schema objects `Dry::Validation.Schema do .. end` (solnic)
|
|
369
|
+
- Ability to define a schema for an array via top-level `each` rule (solnic)
|
|
370
|
+
- Ability to define nested schemas via `key(:location).schema do .. end` (solnic)
|
|
371
|
+
- Ability to re-use schemas inside other schemas via `key(:location).schema(LocationSchema)` (solnic)
|
|
372
|
+
- Ability to inherit rules from another schema via `Dry::Validation.Schema(Other) do .. end` (solnic)
|
|
373
|
+
- Ability to inject arbitrary dependencies to schemas via `Schema.option` + `Schema#with` (solnic)
|
|
374
|
+
- Ability to provide translations for rule names under `%{locale}.rules.%{name}` pattern (solnic)
|
|
375
|
+
- Ability to configure input processor, either `:form` or `:sanitizer` (solnic)
|
|
376
|
+
- Ability to pass a constrained dry type when defining keys or attrs, ie `key(:age, Types::Age)` (solnic)
|
|
377
|
+
- `Result#messages` supports `:full` option to get messages with rule names, disabled by default (solnic)
|
|
378
|
+
- `Validation::Result` responds to `#[]` and `#each` (delegating to its output)
|
|
374
379
|
and it's an enumerable (solnic)
|
|
375
380
|
|
|
376
381
|
### Changed
|
|
377
382
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
383
|
+
- `schema` was **removed** from the DSL, just use `key(:name).schema` instead (solnic)
|
|
384
|
+
- `confirmation` is now a macro that you can call on a key rule (solnic)
|
|
385
|
+
- rule names for nested structures are now fully qualified, which means you can
|
|
381
386
|
provide customized messages for them. ie `user: :email` (solnic)
|
|
382
|
-
|
|
383
|
-
|
|
387
|
+
- `Schema::Result#params` was renamed to `#output` (solnic)
|
|
388
|
+
- `Schema::Result` is now `Validation::Result` and it no longer has success and
|
|
384
389
|
failure results, only error results are provided (solnic)
|
|
385
390
|
|
|
386
391
|
### Fixed
|
|
387
392
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
393
|
+
- Qualified rule names properly use last node by default for error messages (solnic)
|
|
394
|
+
- Validation hints only include relevant messages (solnic)
|
|
395
|
+
- `:yaml` messages respect `:locale` option in `Result#messages` (solnic)
|
|
391
396
|
|
|
392
397
|
[Compare v0.6.0...v0.7.0](https://github.com/dry-rb/dry-validation/compare/v0.6.0...v0.7.0)
|
|
393
398
|
|
|
@@ -395,19 +400,19 @@
|
|
|
395
400
|
|
|
396
401
|
### Added
|
|
397
402
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
403
|
+
- Support for validating objects with attr readers via `attr` (SunnyMagadan)
|
|
404
|
+
- Support for `value` interface in the DSL for composing high-level rules based on values (solnic)
|
|
405
|
+
- Support for `rule(name: :something)` syntax for grouping high-level rules under
|
|
401
406
|
the same name (solnic)
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
407
|
+
- Support for `confirmation(:foo, some_predicate: some_argument)` shortcut syntax (solnic)
|
|
408
|
+
- Support for error messages for grouped rules (like `confirmation`) (solnic)
|
|
409
|
+
- Schemas support injecting rules from the outside (solnic)
|
|
405
410
|
|
|
406
411
|
## Changed
|
|
407
412
|
|
|
408
|
-
|
|
413
|
+
- `rule` uses objects that inherit from `BasicObject` to avoid conflicts with
|
|
409
414
|
predicate names and built-in `Object` methods (solnic)
|
|
410
|
-
|
|
415
|
+
- In `Schema::Form` both `key` and `optional` will apply `filled?` predicate by
|
|
411
416
|
default when no block is passed (solnic)
|
|
412
417
|
|
|
413
418
|
[Compare v0.5.0...v0.6.0](https://github.com/dry-rb/dry-validation/compare/v0.5.0...v0.6.0)
|
|
@@ -416,12 +421,12 @@
|
|
|
416
421
|
|
|
417
422
|
### Changed
|
|
418
423
|
|
|
419
|
-
|
|
420
|
-
|
|
424
|
+
- Now depends on [dry-logic](https://github.com/dry-rb/dry-logic) for predicates and rules (solnic)
|
|
425
|
+
- `dry/validation/schema/form` is now required by default (solnic)
|
|
421
426
|
|
|
422
427
|
### Fixed
|
|
423
428
|
|
|
424
|
-
|
|
429
|
+
- `Schema::Form` uses safe `form.array` and `form.hash` types which fixes #42 (solnic)
|
|
425
430
|
|
|
426
431
|
[Compare v0.4.1...v0.5.0](https://github.com/dry-rb/dry-validation/compare/v0.4.1...v0.5.0)
|
|
427
432
|
|
|
@@ -429,7 +434,7 @@
|
|
|
429
434
|
|
|
430
435
|
### Added
|
|
431
436
|
|
|
432
|
-
|
|
437
|
+
- Support for `each` and type coercion inference in `Schema::Form` (solnic)
|
|
433
438
|
|
|
434
439
|
[Compare v0.4.0...v0.4.1](https://github.com/dry-rb/dry-validation/compare/v0.4.0...v0.4.1)
|
|
435
440
|
|
|
@@ -437,15 +442,15 @@
|
|
|
437
442
|
|
|
438
443
|
### Added
|
|
439
444
|
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
+
- Support for high-level rule composition via `rule` interface (solnic)
|
|
446
|
+
- Support for exclusive disjunction (aka xor/^ operator) (solnic)
|
|
447
|
+
- Support for nested schemas within a schema class (solnic)
|
|
448
|
+
- Support for negating rules via `rule(name).not` (solnic)
|
|
449
|
+
- Support for `validation hints` that are included in the error messages (solnic)
|
|
445
450
|
|
|
446
451
|
### Fixed
|
|
447
452
|
|
|
448
|
-
|
|
453
|
+
- Error messages hash has now consistent structure `rule_name => [msgs_array, input_value]` (solnic)
|
|
449
454
|
|
|
450
455
|
[Compare v0.3.1...v0.4.0](https://github.com/dry-rb/dry-validation/compare/v0.3.1...v0.4.0)
|
|
451
456
|
|
|
@@ -453,11 +458,11 @@
|
|
|
453
458
|
|
|
454
459
|
### Added
|
|
455
460
|
|
|
456
|
-
|
|
461
|
+
- Support for `Range` and `Array` as an argument in `size?` predicate (solnic)
|
|
457
462
|
|
|
458
463
|
### Fixed
|
|
459
464
|
|
|
460
|
-
|
|
465
|
+
- Error compiler returns an empty hash rather than a nil when there are no errors (solnic)
|
|
461
466
|
|
|
462
467
|
[Compare v0.3.0...v0.3.1](https://github.com/dry-rb/dry-validation/compare/v0.3.0...v0.3.1)
|
|
463
468
|
|
|
@@ -465,23 +470,23 @@
|
|
|
465
470
|
|
|
466
471
|
### Added
|
|
467
472
|
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
+
- I18n messages support (solnic)
|
|
474
|
+
- Ability to configure `messages` via `configure { config.messages = :i18n }` (solnic)
|
|
475
|
+
- `rule` interface in DSL for defining rules that depend on other rules (solnic)
|
|
476
|
+
- `confirmation` interface as a shortcut for defining "confirmation of" rule (solnic)
|
|
477
|
+
- Error messages can be now matched by input value type too (solnic)
|
|
473
478
|
|
|
474
479
|
### Fixed
|
|
475
480
|
|
|
476
|
-
|
|
477
|
-
|
|
481
|
+
- `optional` rule with coercions work correctly with `|` + multiple `&`s (solnic)
|
|
482
|
+
- `Schema#[]` checks registered predicates first before defaulting to its own predicates (solnic)
|
|
478
483
|
|
|
479
484
|
### Changed
|
|
480
485
|
|
|
481
|
-
|
|
482
|
-
|
|
486
|
+
- `Schema#messages(input)` => `Schema#call(input).messages` (solnic)
|
|
487
|
+
- `Schema#call` returns `Schema::Result` which has access to all rule results,
|
|
483
488
|
errors and messages
|
|
484
|
-
|
|
489
|
+
- `Schema::Result#messages` returns a hash with rule names, messages and input values (solnic)
|
|
485
490
|
|
|
486
491
|
[Compare v0.2.0...HEAD](https://github.com/dry-rb/dry-validation/compare/v0.2.0...HEAD)
|
|
487
492
|
|
|
@@ -489,10 +494,10 @@
|
|
|
489
494
|
|
|
490
495
|
### Added
|
|
491
496
|
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
497
|
+
- `Schema::Form` with a built-in coercer inferred from type-check predicates (solnic)
|
|
498
|
+
- Ability to pass a block to predicate check in the DSL ie `value.hash? { ... }` (solnic)
|
|
499
|
+
- Optional keys using `optional(:key_name) { ... }` interface in the DSL (solnic)
|
|
500
|
+
- New predicates:
|
|
496
501
|
- `bool?`
|
|
497
502
|
- `date?`
|
|
498
503
|
- `date_time?`
|
|
@@ -504,7 +509,7 @@
|
|
|
504
509
|
|
|
505
510
|
### Fixed
|
|
506
511
|
|
|
507
|
-
|
|
512
|
+
- Added missing `and` / `or` interfaces to composite rules (solnic)
|
|
508
513
|
|
|
509
514
|
[Compare v0.1.0...HEAD](https://github.com/dry-rb/dry-validation/compare/v0.1.0...HEAD)
|
|
510
515
|
|
data/Gemfile
CHANGED
|
@@ -5,11 +5,10 @@ gemspec
|
|
|
5
5
|
group :test do
|
|
6
6
|
gem 'i18n', require: false
|
|
7
7
|
platform :mri do
|
|
8
|
-
gem 'codeclimate-test-reporter', require: false
|
|
9
8
|
gem 'simplecov', require: false
|
|
10
9
|
end
|
|
11
10
|
gem 'dry-monads', '>= 0.4.0', require: false
|
|
12
|
-
gem 'dry-struct',
|
|
11
|
+
gem 'dry-struct', git: 'https://github.com/dry-rb/dry-struct', branch: 'master'
|
|
13
12
|
end
|
|
14
13
|
|
|
15
14
|
group :tools do
|
data/dry-validation.gemspec
CHANGED
|
@@ -17,8 +17,8 @@ Gem::Specification.new do |spec|
|
|
|
17
17
|
spec.add_runtime_dependency 'concurrent-ruby', '~> 1.0'
|
|
18
18
|
spec.add_runtime_dependency 'dry-configurable', '~> 0.1', '>= 0.1.3'
|
|
19
19
|
spec.add_runtime_dependency 'dry-equalizer', '~> 0.2'
|
|
20
|
-
spec.add_runtime_dependency 'dry-logic', '~> 0.
|
|
21
|
-
spec.add_runtime_dependency 'dry-types', '~> 0.
|
|
20
|
+
spec.add_runtime_dependency 'dry-logic', '~> 0.5', '>= 0.5.0'
|
|
21
|
+
spec.add_runtime_dependency 'dry-types', '~> 0.14', '>= 0.14'
|
|
22
22
|
spec.add_runtime_dependency 'dry-core', '~> 0.2', '>= 0.2.1'
|
|
23
23
|
|
|
24
24
|
spec.add_development_dependency 'bundler'
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'dry/logic/predicates'
|
|
2
|
+
|
|
3
|
+
module Dry
|
|
4
|
+
module Validation
|
|
5
|
+
module Predicates
|
|
6
|
+
include Dry::Logic::Predicates
|
|
7
|
+
|
|
8
|
+
class << self
|
|
9
|
+
undef :nil?
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
define_singleton_method :nil?, &Object.method(:nil?)
|
|
13
|
+
|
|
14
|
+
def self.none?(input)
|
|
15
|
+
input.nil?
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require 'dry/configurable'
|
|
2
|
+
require 'dry/validation/predicates'
|
|
2
3
|
require 'dry/validation/messages'
|
|
3
4
|
require 'dry/validation/type_specs'
|
|
4
5
|
|
|
@@ -12,7 +13,7 @@ module Dry
|
|
|
12
13
|
NOOP_INPUT_PROCESSOR = -> input { input }
|
|
13
14
|
|
|
14
15
|
setting :path
|
|
15
|
-
setting :predicates,
|
|
16
|
+
setting :predicates, Dry::Validation::Predicates
|
|
16
17
|
setting :registry
|
|
17
18
|
setting :messages, :yaml
|
|
18
19
|
setting :messages_file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dry-validation
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.13.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andy Holland
|
|
@@ -63,30 +63,42 @@ dependencies:
|
|
|
63
63
|
name: dry-logic
|
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: 0.5.0
|
|
66
69
|
- - "~>"
|
|
67
70
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: 0.
|
|
71
|
+
version: '0.5'
|
|
69
72
|
type: :runtime
|
|
70
73
|
prerelease: false
|
|
71
74
|
version_requirements: !ruby/object:Gem::Requirement
|
|
72
75
|
requirements:
|
|
76
|
+
- - ">="
|
|
77
|
+
- !ruby/object:Gem::Version
|
|
78
|
+
version: 0.5.0
|
|
73
79
|
- - "~>"
|
|
74
80
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: 0.
|
|
81
|
+
version: '0.5'
|
|
76
82
|
- !ruby/object:Gem::Dependency
|
|
77
83
|
name: dry-types
|
|
78
84
|
requirement: !ruby/object:Gem::Requirement
|
|
79
85
|
requirements:
|
|
86
|
+
- - ">="
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
version: '0.14'
|
|
80
89
|
- - "~>"
|
|
81
90
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: 0.
|
|
91
|
+
version: '0.14'
|
|
83
92
|
type: :runtime
|
|
84
93
|
prerelease: false
|
|
85
94
|
version_requirements: !ruby/object:Gem::Requirement
|
|
86
95
|
requirements:
|
|
96
|
+
- - ">="
|
|
97
|
+
- !ruby/object:Gem::Version
|
|
98
|
+
version: '0.14'
|
|
87
99
|
- - "~>"
|
|
88
100
|
- !ruby/object:Gem::Version
|
|
89
|
-
version: 0.
|
|
101
|
+
version: '0.14'
|
|
90
102
|
- !ruby/object:Gem::Dependency
|
|
91
103
|
name: dry-core
|
|
92
104
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -206,6 +218,7 @@ files:
|
|
|
206
218
|
- lib/dry/validation/messages/namespaced.rb
|
|
207
219
|
- lib/dry/validation/messages/yaml.rb
|
|
208
220
|
- lib/dry/validation/predicate_registry.rb
|
|
221
|
+
- lib/dry/validation/predicates.rb
|
|
209
222
|
- lib/dry/validation/result.rb
|
|
210
223
|
- lib/dry/validation/schema.rb
|
|
211
224
|
- lib/dry/validation/schema/check.rb
|
|
@@ -364,8 +377,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
364
377
|
- !ruby/object:Gem::Version
|
|
365
378
|
version: '0'
|
|
366
379
|
requirements: []
|
|
367
|
-
|
|
368
|
-
rubygems_version: 2.7.7
|
|
380
|
+
rubygems_version: 3.0.2
|
|
369
381
|
signing_key:
|
|
370
382
|
specification_version: 4
|
|
371
383
|
summary: A simple validation library
|