forked from dry-rb/dry-schema
-
Notifications
You must be signed in to change notification settings - Fork 0
/
changelog.yml
497 lines (479 loc) · 19.3 KB
/
changelog.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
---
- version: unreleased
summary:
date:
fixed:
- 'Composing schemas no longer crashes in certain scenarios (issue #342 fixed via
#366) (@vsuhachev)'
added:
changed:
- version: 1.8.0
date: '2021-09-12'
changed:
- "[internal] Upgraded to new `setting` API provided in dry-configurable 0.13.0
(@timriley in #356)"
- version: 1.7.1
date: '2021-08-29'
changed:
- "[internal] Use explicit `#to_h` conversion of Dry::Configurable::Config, to ensure
compatibility with upcoming dry-configurable 0.13.0 release (via #371) (@timriley)"
- version: 1.7.0
summary: This release ships with a bunch of internal refactorings that should improve
performance but if you see any unexpected behavior please do report issues.
date: '2021-06-29'
fixed:
- 'Handle arrays of hashes where Array constructor coerces non-Hash input (#351
fixed via #354) (@ojab)'
- 'Run outer schema processor steps before inner ones (issue #350 fixed via #361)
(@ojab)'
- 'Fix key validator false negatives on empty collections (see #363) (@Drenmi)'
- 'Prevent error message YAML files from being parsed multiple times (issue #352
via #364) (@alassek)'
- 'Using constructor types should work fine now ie `required(:foo).filled(Types::Params::Integer.constructor(&:succ))`
(issue #280 fixed via #365) (@solnic)'
- 'Handle non-Hash to Hash transformation in `before(:key_coercer)` (issue #350
fixed via #362) (@ojab)'
added:
changed:
- "[internal] `Dry::Schema::Path` clean up and performance improvements (via #358)
(@ojab)"
- "[internal] simplify and speed up handling of steps in nested schemas (via #360)
(@ojab)"
- version: 1.6.2
summary:
date: '2021-04-15'
fixed:
- Using `respond_to?` predicate in blocks works now (@rindek)
added:
- A default error message for `respond_to?` predicate (@rindek)
changed:
- version: 1.6.1
summary:
date: 2021-02-02
fixed:
- Messages#[] handles meta/no meta cases more gracefully and has better interoperability
with the I18n backend. This brings MessageCompiler#visit_unexpected_key up to
parity with MessageCompiler#visit_predicate. Uses visit_predicate as basis for
visit_unexpected_key. (@robhanlon22)
added:
changed:
- version: 1.6.0
date: '2021-01-21'
fixed:
- 'Using sum types with a i18n backend no longer crashes (issue #328 fixes via #331)
(@tylerhunt)'
changed:
- |-
Inferring predicates from class names is deprecated. It's very unlikely your code depends on it,
however, if it does, you'll get an exception with instructions. (@flash-gordon)
If you see an exception and don't rely on inferring, just disable it with:
```ruby
Dry::Schema::PredicateInferrer::Compiler.infer_predicate_by_class_name false
```
Otherwise, enable it explicitly:
```ruby
Dry::Schema::PredicateInferrer::Compiler.infer_predicate_by_class_name true
```
See https://github.com/dry-rb/dry-schema/issues/335 for rationale.
- version: 1.5.6
summary:
date: '2020-10-21'
fixed:
- 'Fixed stack error which was a regression introduced in 1.5.5 (issue #322 fixed
via #323) (@flash-gordon)'
added:
changed:
- version: 1.5.5
summary:
date: '2020-10-08'
fixed:
- 'Key validation works with messages that have meta-data (issue #310 fixed via
#313) (@tadeusz-niemiec)'
- 'Using an external schema along with a key specified as a `:hash` works as expected
(issue #296 fixed via #315) (@tadeusz-niemiec + @solnic)'
- "`Result#error?(path)` works correctly when the path points to an array item (issue
#317 fixed via #318) (@solnic)"
added:
changed:
- version: 1.5.4
summary: '2020-09-03'
date:
fixed:
- 'Key validation works correctly with a non-nested maybe hashes (issue #311 fixed
via #312) (@svobom57)'
added:
changed:
- version: 1.5.3
summary:
date: '2020-08-21'
fixed:
- 'Key validator works correctly with an array with maybe hash as its member (issue
#308 fixed via #309) (@tadeusz-niemiec)'
added:
changed:
- "[info extension] small performance improvement in the set visitor (see #305 for
more details) (@esparta)"
- version: 1.5.2
summary:
date: '2020-06-26'
fixed:
- "`Result#{success?,failure?}` work as expected when there are only key validation
failures (issue #297 fixed via #298) (@adamransom)"
added:
changed:
- '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)'
- version: 1.5.1
summary:
date: '2020-05-21'
fixed:
- 'Negated predicates support the logic operator API now (fixed via #276 by @solnic)'
- 'Fixed circular require warning (issue #279 closed via #282 by @landongrindheim)'
- 'Validating keys against an array with non-hash members no longer crashes (issue
#283 fixed via #284 by @beechnut and issue #289 fixed via #288 by @tadeusz-niemiec)'
added:
changed:
- version: 1.5.0
summary:
date: '2020-03-11'
fixed:
- |-
`maybe` macro in JSON schemas no longer converts empty strings to `nil`.
This was a bug in dry-types but your code may rely on this behavior. If you still
require this behavior, we recommend using a custom type (see Advanced -> Custom types in the docs) (@flash-gordon)
- YAML message backend no longer crashes when load_paths are empty (@robhanlon22)
- Callbacks can now be inherited from multiple parents (@skryukov)
- 'Callbacks work with nested schemas (issue #209) (@solnic)'
- 'Custom type is respected when defining nested schemas (issue #174 closed via
263) (@solnic)'
- 'Key map is properly inferred for maybe-hashes (issue #266 fixed via #269) (@solnic)'
added:
- 'Support for complex sum types ie `value([:integer, array[:integer])` (issue #214)
(@solnic)'
- 'You can now set global config via `Dry::Schema.config` (issue #205) (@robhanlon22)'
- 'Default error message for `:uuid_v4?` predicate (isssue #230) (@solnic)'
- "[experimental] you can compose schemas in the DSL using the standard logic operators
(issue #231 closed via #245) (@solnic)"
- |-
Hash schema type can now be used with proper keys and predicates inferring. Constructor
and default types are explicitly not supported (@flash-gordon)
```ruby
UserType = Dry::Types['hash'].schema(
name: 'string',
email: 'string'
)
Dry::Schema.define do
require(:user).hash(UserType)
end
```
- "`:struct` extension which allows using dry-struct classes as source for hash
schemas. Note that output will still be presented as plain hashes, returning structs
from schemas will require more work, it's planned for next versions (@flash-gordon)"
- "`:info` extension which adds #info method to your schemas which produces a simple
hash providing information about keys and types (issue #36 closed via #262) (@solnic)"
changed:
- "`:i18n` message backend delegates interpolation and caching to `I18n` (issue
#211) (@robhanlon22)"
- Raise ArgumentError in DSL if parent DSL configs differ (@robhanlon22)
- "(internal) `PredicateInferrer` was removed. `Dry::Types::PredicateInferrer` is
a drop-in replacement (@flash-gordon)"
- version: 1.4.3
date: '2020-01-08'
added:
- |-
Pattern matching for `Dry::Schema::Result` objects (@flash-gordon)
```ruby
schema = Dry::Schema::Params { required(:name).filled }
case schema.('name' => 'John')
in name:
name # => 'John'
end
```
Try it with monads!
- |-
Shortcut for nested schemas in `value` and `maybe` macros (@waiting-for-dev)
```ruby
Dry::Schema.Params do
required(:address).value(:hash) do
required(:city).filled
end
end
```
fixed:
- Some keyword warnings that slipped into the previous release (@flash-gordon)
- version: 1.4.2
date: '2019-12-19'
fixed:
- "`I18n` messages backend supports procs as text properly (issue #208) (@robhanlon22)"
- "`I18n` messages backend supports message meta-data (issue #210) (@robhanlon22)"
- Fixed keyword warnings from MRI 2.7.0 (@flash-gordon)
- 'Array with a member works correctly with `maybe` (issue #206) (@solnic)'
- version: 1.4.1
date: '2019-10-08'
fixed:
- Child schemas no longer mutate processing steps of their parent classes (@skryukov)
- version: 1.4.0
date: '2019-10-08'
added:
- |-
Support for passing multiple parent schemas. They are inherited from left to right (@ianwhite)
```ruby
Dry::Schema.define(parent: [parent_a, parent_b, parent_c]) do
...
end
```
- Improved error messages about missing translations (@skryukov)
- |-
[experimental] before/after callbacks for schema steps (@skryukov)
```ruby
Dry::Schema.Params do
required(:name).value(:string)
optional(:age).value(:integer)
before(:value_coercer) do |result|
result.to_h.compact
end
end
```
fixed:
- Added/fixed support for custom optional types (@flash-gordon)
- version: 1.3.4
date: '2019-09-11'
fixed:
- 'Fixed regression where using `array?` predicate within a block would crach (issue
#186) (@skryukov)'
- version: 1.3.3
date: '2019-08-14'
fixed:
- 'Reject attempts to build a nested schema for array types built on `Dry::Types::Nominal`
(fixed #171) (@flash-gordon)'
- Current `I18n.locale` is now properly handled when caching message templates (@flash-gordon)
- Default processor uses strict types by default, which fixes various cases when
`maybe` is used with a constructor type (@flash-gordon)
- 'Namespaced messages no longer causes a crash when used with nested schemas (fixed
#176) (@solnic)'
- version: 1.3.2
date: '2019-08-01'
added:
- 'Support for new predicates: `bytesize?`, `min_bytesize?` and `max_bytesize?`
(@bmalinconico)'
- version: 1.3.1
date: '2019-07-08'
fixed:
- "`Result#error?` works correctly with nested hashes and arrays (@solnic)"
- "`:hints` extension no longer causes a crash where base messages are generated
too (issue #165) (@solnic)"
- version: 1.3.0
date: '2019-07-06'
added:
- |-
Automatic predicate inferring for constrained types! (@flash-gordon)
```ruby
Types::Name = Types::String.constrained(min_size: 1)
schema = Dry::Schema.define do
required(:name).value(Types::Name)
end
schema.(name: '').errors.to_h # => { name: ["size cannot be less than 1"] }
```
- 'Support for redefining re-used schemas (issue #43) (@skryukov)'
fixed:
- Type container is passed down to nested schemas (@flash-gordon)
- version: 1.2.0
date: '2019-06-13'
added:
- |-
Ability to configure your own type container (@Morozzzko)
```ruby
types = Dry::Schema::TypeContainer.new
types.register(
'params.trimmed_string',
Types::String.constructor(&:strip).constructor(&:downcase)
)
Dry::Schema.Params do
config.types = types
require(:name).value(:trimmed_string)
end
```
fixed:
- "`filled` macro no longer generates incorrect messages for arrays (issue #151)
(@solnic)"
- "`filled` macro works correctly with constructor types (@solnic)"
- "`filled` works correctly with nested schemas (#149) (@solnic + @timriley)"
- Custom array constructors are no longer discredited by `array` macro (@solnic)
- "`BigDecimal` type is correctly handled by predicate inference (@solnic)"
- Works with latest `dry-logic` which provides the new `respond_to?` predicate (#153)
(@flash-gordon)
changed:
- Fixes related to `filled` restored pre-1.1.0 behavior of `:hints` which are again
included (@solnic)
- "`filled` no longer uses filter rules to handle empty strings in `Params` (@solnic)"
- version: 1.1.0
date: '2019-05-30'
added:
- "`config.messages.default_locale` for setting...default locale (surprise, surprise)
(@solnic)"
- "`Config` exposes `predicates` setting too (@solnic)"
fixed:
- "`filled` macro behavior results in `must be filled` error messages when appropriate
- see PR #141 for more information (issue #134) (@solnic)"
- 'Filter rules no longer cause keys to be added to input (issue #142) (@solnic)'
- Filter rules work now with inheritance (@solnic)
- Inherited type schemas used by coercion are now properly configured as `lax` type
(@solnic)
- "`Config` is now finalized before instantiating schemas and properly dupped when
its inherited (@flash-gordon + @solnic)"
- "`Config#eql?` works as expected (@solnic)"
- 'Predicates are properly inferred from array with a member type spec, ie `array[:integer]`
results in `array? + each(:integer?)` (issue #140) (@solnic)'
- version: 1.0.3
date: '2019-05-21'
fixed:
- "`Object#hash` is no longer used to calculate cache keys due to a potential risk
of having hash collisions (@solnic)"
- Predicate arguments are used again for template cache keys (@solnic)
- "`I18n` messages backend no longer evaluates templates twice (@solnic)"
- version: 1.0.2
date: '2019-05-12'
fixed:
- 'Caching message templates uses restricted set of known keys to calculate cache
keys (issue #132) (@solnic)'
- version: 1.0.1
date: '2019-05-08'
fixed:
- 'Applying `key?` predicate no longer causes recursive calls to `Result#errors`
(issue #130) (@solnic)'
- version: 1.0.0
date: '2019-05-03'
changed:
- "[BREAKING] `Result#to_hash` was removed (@solnic)"
fixed:
- Setting `:any` as the type spec no longer crashes (@solnic)
- "`Result#error?` handles paths to array elements correctly (@solnic)"
- version: 0.6.0
date: '2019-04-24'
changed:
- Dependency on `dry-types` was bumped to `~> 1.0` (@solnic)
- Dependency on `dry-logic` was bumped to `~> 1.0` (@solnic)
- Dependency on `dry-initializer` was bumped to `~> 3.0` (@solnic)
- version: 0.5.1
date: '2019-04-17'
fixed:
- 'Key map no longer crashes on unexpected input (issue #118) (@solnic)'
- version: 0.5.0
date: '2019-04-04'
added:
- |-
Support for arbitrary meta-data in messages, ie:
```yaml
en:
dry_schema:
errors:
filled?:
text: "cannot be blank"
code: 123
```
Now your error hash will include `{ foo: [{ text: 'cannot be blank', code: 123 }] }` (@solnic + @flash-gordon)
- Support for type specs in `array` macro, ie `required(:tags).array(:integer)`
(@solnic)
- Support for type specs in `each` macro, ie `required(:tags).each(:integer)` (@solnic)
- |-
Shortcut for defining an array with hash as its member, ie:
```ruby
Dry::Schema.Params do
required(:tags).array(:hash) do
required(:name).filled(:string)
end
end
```
fixed:
- Inferring predicates doesn't crash when `Any` type is used (@flash-gordon)
- Inferring type specs when type is already set works correctly (@solnic)
changed:
- "[BREAKING] `:monads` extension wraps entire result objects in `Success` or `Failure`
(@flash-gordon)"
- When `:hints` are disabled, result AST will not include hint nodes (@solnic)
- version: 0.4.0
date: '2019-03-26'
added:
- 'Schemas are now compatible with procs via `#to_proc` (issue #53) (@solnic)'
- Support for configuring `top_namespace` for localized messages (@solnic)
- Support for configuring more than one load path for localized messages (@solnic)
- 'Support for inferring predicates from arbitrary types (issue #101) (@solnic)'
fixed:
- 'Handling of messages for `optional` keys without value rules works correctly
(issue #87) (@solnic)'
- 'Message structure for `optional` keys with an array of hashes no longer duplicates
keys (issue #89) (@solnic)'
- 'Inferring `:date_time?` predicate works correctly with `DateTime` types (issue
#97) (@solnic)'
changed:
- "[BREAKING] Updated to work with `dry-types 0.15.0` (@flash-gordon)"
- "[BREAKING] `Result#{errors,messages,hints}` returns `MessageSet` object now which
is an enumerable coercible to a hash (@solnic)"
- "[BREAKING] `Messages` backend classes no longer use global configuration (@solnic)"
- "[BREAKING] Passing a non-symbol key name in the DSL will raise `ArgumentError`
(issue #29) (@solnic)"
- |-
[BREAKING] Configuration for message backends is now nested under `messages` key with following settings:
- `messages.backend` - previously `messages`
- `messages.load_paths` - previously `messages_path`
- `messages.namespace` - previously `namespace`
- `messages.top_namespace` - **new setting** see above
- "[BREAKING] `Messages::I18n` uses `I18.store_translations` instead of messing
with `I18n.load_path` (@solnic)"
- Schemas (`Params` and `JSON`) have nicer inspect (@solnic)
- version: 0.3.0
date: '2018-03-04'
fixed:
- Configuration is properly inherited from a parent schema (@skryukov)
- "`Result#error?` returns `true` when a preceding key has errors (@solnic)"
- Predicate inferrer no longer chokes on sum, constructor and enum types (@solnic)
- Predicate inferrer infers `:bool?` from boolean types (@solnic)
- Block-based definitions using `array` works correctly (@solnic)
- Using a disjunction with `array` and `hash` produces correct errors when element
validation for array failed (@solnic)
changed:
- Required ruby version was removed from gemspec for people who are stuck on MRI
2.3.x (@solnic)
- version: 0.2.0
date: '2019-02-26'
added:
- New `hash` macro which prepends `hash?` type-check and allows nested schema definition
(@solnic)
- New `array` macro which works like `each` but prepends `array?` type-check (@solnic)
fixed:
- 'Rule name translation works correctly with I18n (issue #52) (@solnic)'
- 'Rule name translation works correctly with namespaced messages (both I18n and
plain YAML) (issue #57) (@solnic)'
- 'Error messages under namespaces are correctly resolved for overridden names (issue
#53) (@solnic)'
- 'Namespaced error messages work correctly when schemas are reused within other
schemas (issue #49) (@solnic)'
- 'Child schema can override inherited rules now (issue #66) (@skryukov)'
- 'Hints are correctly generated for disjunction that use type-check predicates
(issue #24) (@solnic)'
- 'Hints are correctly generated for nested schemas (issue #26) (@solnic)'
- "`filled` macro respects inferred type-check predicates and puts them in front
(@solnic)"
- 'Value coercion works correctly with re-usable nested schemas (issue #25) (@solnic)'
changed:
- "[BREAKING] **Messages are now configured under `dry_schema` namespace by default**
(issue #38) (@solnic)"
- "[BREAKING] Hints are now an optional feature provided by `:hints` extension,
to load it do `Dry::Schema.load_extensions(:hints)` (@solnic)"
- "[BREAKING] Hints generation was improved in general, output of `Result#messages`
and `Result#hints` changed in some cases (@solnic)"
- "[BREAKING] `schema` macro no longer prepends `hash?` check, for this behavior
use the new `hash` macro (see #31) (@solnic)"
- "[BREAKING] Support for MRI < 2.4 was dropped (@solnic)"
- version: 0.1.1
date: '2019-02-17'
added:
- "`Result#error?` supports checking nested errors too ie`result.error?('user.address')`
(@solnic)"
fixed:
- 'Fix issues with templates and invalid tokens (issue #27) (@solnic)'
- Fix Ruby warnings (@flash-gordon)
- version: 0.1.0
date: '2019-01-30'
summary: Initial release.