decoders 2.1.0 → 2.2.0-test

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.
Files changed (99) hide show
  1. package/README.md +12 -12
  2. package/dist/annotate-0PUmWHxH.d.cts +33 -0
  3. package/dist/annotate-0PUmWHxH.d.ts +33 -0
  4. package/dist/chunk-2C72BP5L.cjs +179 -0
  5. package/dist/chunk-2C72BP5L.cjs.map +1 -0
  6. package/dist/chunk-BPSZE2VX.js +13 -0
  7. package/dist/chunk-BPSZE2VX.js.map +1 -0
  8. package/dist/chunk-Q3YXBCTD.cjs +13 -0
  9. package/dist/chunk-Q3YXBCTD.cjs.map +1 -0
  10. package/dist/chunk-RUMDX66L.js +179 -0
  11. package/dist/chunk-RUMDX66L.js.map +1 -0
  12. package/dist/format.cjs +13 -0
  13. package/dist/format.cjs.map +1 -0
  14. package/dist/format.d.cts +9 -0
  15. package/dist/format.d.ts +9 -0
  16. package/dist/format.js +13 -0
  17. package/dist/format.js.map +1 -0
  18. package/dist/index.cjs +659 -0
  19. package/dist/index.cjs.map +1 -0
  20. package/dist/index.d.cts +454 -0
  21. package/dist/index.d.ts +454 -0
  22. package/dist/index.js +659 -0
  23. package/dist/index.js.map +1 -0
  24. package/dist/result.cjs +9 -0
  25. package/dist/result.cjs.map +1 -0
  26. package/dist/result.d.cts +26 -0
  27. package/dist/result.d.ts +26 -0
  28. package/dist/result.js +9 -0
  29. package/dist/result.js.map +1 -0
  30. package/format.cjs +13 -0
  31. package/package.json +163 -100
  32. package/result.cjs +9 -0
  33. package/CHANGELOG.md +0 -670
  34. package/Decoder.d.ts +0 -94
  35. package/Decoder.js +0 -105
  36. package/Decoder.js.flow +0 -286
  37. package/Decoder.mjs +0 -101
  38. package/NotSupportedTSVersion.d.ts +0 -1
  39. package/_utils.d.ts +0 -9
  40. package/_utils.js +0 -80
  41. package/_utils.js.flow +0 -107
  42. package/_utils.mjs +0 -70
  43. package/annotate.d.ts +0 -62
  44. package/annotate.js +0 -145
  45. package/annotate.js.flow +0 -218
  46. package/annotate.mjs +0 -131
  47. package/format.d.ts +0 -6
  48. package/format.js +0 -117
  49. package/format.js.flow +0 -128
  50. package/format.mjs +0 -110
  51. package/index.d.ts +0 -40
  52. package/index.js +0 -67
  53. package/index.js.flow +0 -44
  54. package/index.mjs +0 -11
  55. package/lib/_helpers.d.ts +0 -79
  56. package/lib/arrays.d.ts +0 -59
  57. package/lib/arrays.js +0 -85
  58. package/lib/arrays.js.flow +0 -138
  59. package/lib/arrays.mjs +0 -75
  60. package/lib/basics.d.ts +0 -93
  61. package/lib/basics.js +0 -74
  62. package/lib/basics.js.flow +0 -124
  63. package/lib/basics.mjs +0 -60
  64. package/lib/booleans.d.ts +0 -16
  65. package/lib/booleans.js +0 -21
  66. package/lib/booleans.js.flow +0 -22
  67. package/lib/booleans.mjs +0 -15
  68. package/lib/dates.d.ts +0 -15
  69. package/lib/dates.js +0 -23
  70. package/lib/dates.js.flow +0 -40
  71. package/lib/dates.mjs +0 -17
  72. package/lib/json.d.ts +0 -35
  73. package/lib/json.js +0 -25
  74. package/lib/json.js.flow +0 -50
  75. package/lib/json.mjs +0 -18
  76. package/lib/numbers.d.ts +0 -31
  77. package/lib/numbers.js +0 -34
  78. package/lib/numbers.js.flow +0 -46
  79. package/lib/numbers.mjs +0 -25
  80. package/lib/objects.d.ts +0 -76
  81. package/lib/objects.js +0 -138
  82. package/lib/objects.js.flow +0 -238
  83. package/lib/objects.mjs +0 -128
  84. package/lib/strings.d.ts +0 -54
  85. package/lib/strings.js +0 -54
  86. package/lib/strings.js.flow +0 -90
  87. package/lib/strings.mjs +0 -40
  88. package/lib/unions.d.ts +0 -55
  89. package/lib/unions.js +0 -82
  90. package/lib/unions.js.flow +0 -155
  91. package/lib/unions.mjs +0 -75
  92. package/lib/utilities.d.ts +0 -40
  93. package/lib/utilities.js +0 -44
  94. package/lib/utilities.js.flow +0 -65
  95. package/lib/utilities.mjs +0 -35
  96. package/result.d.ts +0 -16
  97. package/result.js +0 -21
  98. package/result.js.flow +0 -26
  99. package/result.mjs +0 -15
package/CHANGELOG.md DELETED
@@ -1,670 +0,0 @@
1
- ## v2.1.0
2
-
3
- - Officially drop Node 12 and 14 support (they may still work)
4
- - Fix unintentional inclusion of `lib.dom.d.ts` in TypeScript
5
-
6
- ## v2.0.5
7
-
8
- - The returned value for `positiveInteger(-0)` is now `0`, not `-0`
9
- - The returned value for `positiveNumber(-0)` is now `0`, not `-0`
10
-
11
- ## v2.0.4
12
-
13
- - Fix a bug in the `url` decoder, which could incorrectly reject URLs with a `/` in the
14
- query path. Thanks, @gcampax!
15
-
16
- ## v2.0.3
17
-
18
- - Fix bundling issue where TypeScript types would not get picked up correctly in old
19
- TypeScript versions. Thanks, @robinchow!
20
-
21
- - ![](./docs/assets/tiny-ts-logo.png) Fix TypeScript types for `Result` type to allow
22
- implicit-undefineds.
23
-
24
- ## v2.0.2
25
-
26
- - ![](./docs/assets/tiny-ts-logo.png) Fix TypeScript types for `formatShort` and
27
- `formatInline` helper functions
28
-
29
- ## v2.0.1
30
-
31
- - ![](./docs/assets/tiny-ts-logo.png) **TypeScript-only:** Fix definition of JSONObject
32
- to reflect that its values might always be `undefined` as well.
33
-
34
- - ![](./docs/assets/tiny-ts-logo.png) **TypeScript-only:** Changed return types of
35
- `{ [key: string]: T }` to `Record<string, T>`.
36
-
37
- - ![](./docs/assets/tiny-ts-logo.png) **TypeScript-only:** Fine-tune the type of
38
- [`instanceOf()`](https://decoders.cc/api.html#instanceOf).
39
-
40
- ## v2.0.0
41
-
42
- This is a breaking change, which brings numerous benefits:
43
-
44
- - A **simpler API** 😇
45
- - Smaller **bundle size** (67% reduction 😱)
46
- - **Tree-shaking** support 🍃
47
- - Runtime **speed** 🏎️
48
- - Better documentation 📚
49
- - Better support for writing your own decoders 🛠️
50
-
51
- <img alt="Bundle size comparison between v1 and v2" src="./docs/assets/size-comparison@2x.png" style="width: 100%; max-width: 829px" width="829" />
52
-
53
- Please see the [migration guide](./MIGRATING-v2.md) for precise instructions on how to
54
- adjust your v1 code.
55
-
56
- The main change is the brand new `Decoder<T>` API! The **tl;dr** is:
57
-
58
- | Replace this v1 pattern... | | ...with this v2 API | Notes |
59
- | :----------------------------------- | --- | :----------------------------------------- | :--------------------------------------------------------------------------- |
60
- | `mydecoder(input)` | → | `mydecoder.decode(input)` | [migration instructions](./MIGRATING-v2.md#stop-calling-decoders) |
61
- | `guard(mydecoder)(input)` | → | `mydecoder.verify(input)` | [migration instructions](./MIGRATING-v2.md#guards-are-no-longer-a-thing) |
62
- | `map(mydecoder, ...)` | → | `mydecoder.transform(...)` | [migration instructions](./MIGRATING-v2.md#map-is-now-transform) |
63
- | `compose(mydecoder, predicate(...))` | → | `mydecoder.refine(...)` | [migration instructions](./MIGRATING-v2.md#compose--predicate-is-now-refine) |
64
- | `describe(mydecoder, ...)` | → | `mydecoder.describe(...)` | |
65
- | `mydecoder(input).value()` | → | `mydecoder.value(input)` | |
66
- | `either`, `either3`, ..., `either9` | → | `either` | [migration instructions](./MIGRATING-v2.md#eitherN-is-now-simply-either) |
67
- | `tuple1`, `tuple2`, ... `tuple6` | → | `tuple` | [migration instructions](./MIGRATING-v2.md#tupleN-is-now-simply-tuple) |
68
- | `dispatch` | → | `taggedUnion` | [migration instructions](./MIGRATING-v2.md#dispatch-is-now-taggedUnion) |
69
- | `url(...)` | → | `httpsUrl` / `url` (signature has changed) | [migration instructions](./MIGRATING-v2.md#signature-of-url-has-changed) |
70
-
71
- The full documentation is available on [**decoders.cc**](https://decoders.cc).
72
-
73
- Other features:
74
-
75
- - Include ES modules in published NPM builds (yay tree-shaking! 🍃)
76
- - Much smaller total bundle size (**67% smaller** compared to v1 😱)
77
-
78
- Other potentially breaking changes:
79
-
80
- - Drop support for all Node versions below 12.x
81
- - Drop support for TypeScript versions below 4.1.0
82
- - Drop support for Flow versions below 0.142.0
83
- - Drop all package dependencies
84
- - Direct reliance on `lemons` has been removed
85
-
86
- New decoders:
87
-
88
- - [`always`](https://decoders.cc/api.html#always)
89
- - [`anyNumber`](https://decoders.cc/api.html#anyNumber)
90
- - [`never`](https://decoders.cc/api.html#never)
91
- - [`prep()`](https://decoders.cc/api.html#prep)
92
- - [`set()`](https://decoders.cc/api.html#set)
93
- - [`uuid`](https://decoders.cc/api.html#uuid)
94
- - [`uuidv1`](https://decoders.cc/api.html#uuidv1)
95
- - [`uuidv4`](https://decoders.cc/api.html#uuidv4)
96
-
97
- Other improvements:
98
-
99
- - [`optional()`](https://decoders.cc/api.html#optional),
100
- [`nullable()`](https://decoders.cc/api.html#nullable), and
101
- [`maybe()`](https://decoders.cc/api.html#maybe) now each take an optional 2nd param to
102
- specify a default value
103
- - Better error messages for nested `either`s
104
-
105
- Implementation changes:
106
-
107
- - Major reorganization of internal module structure
108
- - Various simplification of internals
109
-
110
- ## v1.25.5
111
-
112
- - Fix compatibility issue with TypeScript projects configured with
113
- `strictNullChecks: false` (or `strict: false`) (Thanks, @stevekrouse and @djlauk!)
114
-
115
- - Officially support Node 16.x
116
-
117
- ## v1.25.4
118
-
119
- - Expose `nonEmptyArray` function in TypeScript (Thanks, @mszczepanczyk!)
120
-
121
- ## v1.25.3
122
-
123
- - Argument to `constant(...)` now has to be scalar value in both Flow and TypeScript,
124
- which matches its intended purpose.
125
-
126
- ## v1.25.2
127
-
128
- - Avoid the need for having to manually specify "as const" in TypeScript when using
129
- `constant()`. (Thanks, @schmod!)
130
-
131
- ## v1.25.1
132
-
133
- - Add support for Flow 0.154.0
134
-
135
- ## v1.25.0
136
-
137
- - Fix signature of `oneOf()` to reflect it can only be used with scalar/constant values
138
-
139
- - In TypeScript, the inferred type for `oneOf(['foo', 'bar'])` will now be
140
- `Decoder<'foo' | 'bar'>` instead of `Decoder<string>` 🎉
141
-
142
- - Drop support for Flow versions < 0.115.0
143
-
144
- ## v1.24.1
145
-
146
- - Tighten up signature types to indicate that incoming arrays won't get mutated
147
-
148
- ## v1.24.0
149
-
150
- - **New decoders:**
151
-
152
- - [`describe`](https://github.com/nvie/decoders#describe): change the error message
153
- for an existing decoder
154
-
155
- - Add support for Flow 0.153.x
156
-
157
- - Drop support for Node 13.x (unstable)
158
-
159
- ## v1.23.5
160
-
161
- TypeScript types:
162
-
163
- - Add missing export for `tuple1`
164
-
165
- ## v1.23.4
166
-
167
- TypeScript types:
168
-
169
- - Add missing export for `nonEmptyString`
170
-
171
- ## v1.23.3
172
-
173
- - Returned objects that are the result from `object()`, `inexact()`, and `exact()`
174
- decoders will no longer contain explicit `undefined` values for optional keys, but
175
- instead those keys will be missing in the returned object entirely. (#574, thanks
176
- @w01fgang!)
177
-
178
- ## v1.23.2
179
-
180
- - Add missing exports for `nonEmptyArray` and `nonEmptyString` (for TypeScript)
181
-
182
- ## v1.23.1
183
-
184
- - Include an error code with every FlowFixMe suppression (Flow 0.132.x compatibility)
185
-
186
- ## v1.23.0
187
-
188
- - **New decoders:**
189
-
190
- - [`json`](https://github.com/nvie/decoders#json): decodes any valid JSON value
191
-
192
- - [`jsonObject`](https://github.com/nvie/decoders#jsonObject): decodes any valid
193
- JSON object
194
-
195
- - [`jsonArray`](https://github.com/nvie/decoders#jsonArray): decodes any valid JSON
196
- array
197
-
198
- ## v1.22.2
199
-
200
- - **New decoders:**
201
-
202
- - [`inexact()`](https://github.com/nvie/decoders#inexact): like object, but retain
203
- any extra fields on the input value as `unknown`
204
-
205
- - [`iso8601`](https://github.com/nvie/decoders#iso8601): for decoding
206
- ISO8601-formatted date strings
207
-
208
- - **Improved type inference** for `object()` and `exact()` decoders (see #515, thanks
209
- @dimfeld)
210
-
211
- - `DecoderType` is now an alias for `$DecoderType` (to support both TypeScript and Flow
212
- conventional naming)
213
-
214
- - `GuardType` (and `$GuardType`) is a new type function to extract the type of a guard
215
- instance
216
-
217
- ## v1.21.0
218
-
219
- - **New decoder** [`lazy()`](https://github.com/nvie/decoders#lazy): lazily-evaluated
220
- decoder, suitable to define self-referential types.
221
-
222
- - Fix compatibility with Flow 0.127.0
223
-
224
- ## v1.20.2
225
-
226
- - Fix compatibility with Flow 0.126.0+
227
-
228
- ## v1.20.1
229
-
230
- - Upgrade debrief to correct (final) version
231
-
232
- ## v1.20.0
233
-
234
- - Fix issue where infinite recursion occurs when input object (the object being
235
- validated) contains a circular reference
236
-
237
- ## v1.19.1
238
-
239
- - Republish due to an NPM outage
240
-
241
- ## v1.19.0
242
-
243
- **New decoders:**
244
-
245
- - To complement the tuple family of decoders, there's now also `tuple1` (thanks
246
- @sfarthin!)
247
-
248
- ## v1.18.1
249
-
250
- - Also fix Flow type bugs when Flow option `exact_by_default=true` in `debrief`
251
- dependency
252
-
253
- ## v1.18.0
254
-
255
- **New decoders:**
256
-
257
- - `nonEmptyString`: like `string`, but will fail on inputs with only whitespace (or the
258
- empty string)
259
-
260
- - `nonEmptyArray`: like `array`, but will fail on inputs with 0 elements
261
-
262
- **Fixes:**
263
-
264
- - Fix Flow type bugs when Flow option `exact_by_default=true` is enabled
265
-
266
- ## v1.17.0
267
-
268
- May cause breakage for Flow users:
269
-
270
- - Fix subtle bug in `object()` and `exact()` Flow type definitions that could cause Flow
271
- to leak `any` under rare circumstances.
272
-
273
- ## v1.16.1
274
-
275
- - Internal change to make the code Flow 0.105.x compatible. Basically stops using array
276
- spreads (`[...things]`) in favor of `Array.from()`.
277
-
278
- ## v1.16.0
279
-
280
- **New feature:**
281
-
282
- - Allow `map()` calls to throw an exception in the mapper function to reject the
283
- decoder. Previously, these mapper functions were not expected to ever throw.
284
-
285
- ## v1.15.0
286
-
287
- **New features:**
288
-
289
- - Support constructors that have required arguments in `instanceOf` decoders in
290
- TypeScript (see #308, thanks @Jessidhia!)
291
- - Add support for type predicates in `predicate()` in TypeScript (see #310, thanks
292
- @Jessidhia!)
293
-
294
- **Fixes:**
295
-
296
- - Add support for Flow >= 0.101.0
297
-
298
- ## v1.14.0
299
-
300
- **Potential breaking changes:**
301
-
302
- - Stricten `pojo` criteria. Now, custom classes like `new String()` or `new Error()`
303
- will not be accepted as a plain old Javascript object (= pojo) anymore.
304
-
305
- **Fixes:**
306
-
307
- - Add support for Flow 0.98+
308
-
309
- ## v1.13.1
310
-
311
- **Fixes:**
312
-
313
- - Don't reject URLs that contains commas (`,`)
314
-
315
- ## v1.13.0
316
-
317
- **Breaking changes:**
318
-
319
- - Changed the API interface of `dispatch()`. The previous version was too complicated
320
- and was hardly used. The new version is easier to use in practice, and has better type
321
- inference support in TypeScript and Flow.
322
-
323
- **Previous usage:**
324
-
325
- ```
326
- const shape = dispatch(
327
- field('type', string),
328
- type => {
329
- switch (type) {
330
- case 'rect': return rectangle;
331
- case 'circle': return circle;
332
- }
333
- return fail('Must be a valid shape');
334
- }
335
- );
336
- ```
337
-
338
- **New usage:**
339
-
340
- ```
341
- const shape = dispatch('type', { rectangle, circle });
342
- ```
343
-
344
- Where `rectangle` and `circle` are decoders of which exactly one will be invoked.
345
-
346
- * Removed the `field()` decoder. It was not generic enough to stay part of the standard
347
- decoder library. (It was typically used in combination with `dispatch()`, which now
348
- isn't needed anymore, see above.)
349
-
350
- * `pojo` decoder now returns `Decoder<{[string]: mixed}>` instead of the unsafe
351
- `Decoder<Object>`.
352
-
353
- **Fixes and cleanup:**
354
-
355
- - Internal reorganization of modules
356
- - Improve TypeScript support
357
- - Reorganization of TypeScript declarations
358
- - More robust test suite for TypeScript
359
- - 100% TypeScript test coverage
360
-
361
- ## v1.12.0
362
-
363
- **New decoders:**
364
-
365
- - `oneOf(['foo', 'bar'])` will return only values matching the given values
366
- - `instanceOf(...)` will return only values that are instances of the given class. For
367
- example: `instanceOf(TypeError)`.
368
-
369
- ## v1.11.1
370
-
371
- - Reduce bundle size for web builds
372
- - New build system
373
- - Cleaner package output
374
-
375
- ## v1.11.0
376
-
377
- **Potentially breaking changes:**
378
-
379
- - Decoders now all take `mixed` (TypeScript: `unknown`) arguments, instead of `any` 🎉 !
380
- This ensures that the proper type refinements in the implementation of your decoder
381
- are made. (See migration notes below.)
382
- - Invalid dates (e.g. `new Date('not a date')`) won’t be considered valid by the `date`
383
- decoder anymore.
384
-
385
- **New features:**
386
-
387
- - `guard()` now takes a config option to control how to format error messages. This is
388
- done via the `guard(..., { style: 'inline' })` parameter.
389
-
390
- - `'inline'`: echoes back the input value and inlines errors (default);
391
- - `'simple'`: just returns the decoder errors. Useful for use in sensitive contexts.
392
-
393
- - Export `$DecoderType` utility type so it can be used outside of the decoders library.
394
-
395
- **Fixes:**
396
-
397
- - Fixes for some TypeScript type definitions.
398
- - Add missing documentation.
399
-
400
- **Migration notes:**
401
-
402
- If your decoder code breaks after upgrading to 1.11.0, please take the following measures
403
- to upgrade:
404
-
405
- 1. If you wrote any custom decoders of this form yourself:
406
-
407
- ```javascript
408
- const mydecoder = (blob: any) => ...
409
- // ^^^ Decoder function taking `any`
410
- ```
411
-
412
- You should now convert those to:
413
-
414
- ```javascript
415
- const mydecoder = (blob: mixed) => ...
416
- // ^^^^^ Decoders should take `mixed` from now on
417
- ```
418
-
419
- Or, for TypeScript:
420
-
421
- ```javascript
422
- const mydecoder = (blob: unknown) => ...
423
- // ^^^^^^^ `unknown` for TypeScript
424
- ```
425
-
426
- Then follow and fix type errors that pop up because you were making assumptions that
427
- are now caught by the type checker.
428
-
429
- 2. If you wrote any decoders based on `predicate()`, you may have code like this:
430
-
431
- ```javascript
432
- const mydecoder: Decoder<string> = predicate(
433
- (s) => s.startsWith('x'),
434
- 'Must start with "x"',
435
- );
436
- ```
437
-
438
- You'll have to change the explicit Decoder type of those to take two type arguments:
439
-
440
- ```javascript
441
- const mydecoder: Decoder<string, string> = predicate(
442
- // ^^^^^^ Provide the input type to predicate() decoders
443
- (s) => s.startsWith('x'),
444
- 'Must start with "x"',
445
- );
446
- ```
447
-
448
- This now explicitly records that `predicate()` makes assumptions about its input
449
- type—previously this wasn’t get caught correctly.
450
-
451
- ## v1.10.6
452
-
453
- - Make Flow 0.85 compatible
454
-
455
- ## v1.10.5
456
-
457
- - Update to latest debrief (which fixes a TypeScript bug)
458
-
459
- ## v1.10.4
460
-
461
- - Drop dependency on babel-runtime to reduce bundle size
462
-
463
- ## v1.10.3
464
-
465
- - Fix minor declaration issue in TypeScript definitions
466
-
467
- ## v1.10.2
468
-
469
- - Tuple decoder error messages now show decoder errors in all positions, not just the
470
- first occurrence.
471
-
472
- **New decoders:**
473
-
474
- - New tuple decoders: `tuple3`, `tuple4`, `tuple5`, and `tuple6`
475
- - `unknown` decoder is an alias of `mixed`, which may be more recognizable for
476
- TypeScript users.
477
-
478
- ## v1.10.1
479
-
480
- - TypeScript support
481
-
482
- ## v1.10.0
483
-
484
- **Breaking:**
485
-
486
- - Private helper function `undefined_or_null` was accidentally exported in the package.
487
- This is a private API.
488
-
489
- ## v1.9.0
490
-
491
- **New decoder:**
492
-
493
- - `dict()` is like `mapping()`, but will return an object rather than a Map instance,
494
- which may be more convenient to handle in most cases.
495
-
496
- **Breaking:**
497
-
498
- - `optional(..., /* allowNull */ true)` has been removed (was deprecated since 1.8.3)
499
-
500
- ## v1.8.3
501
-
502
- **New decoder:**
503
-
504
- - `maybe()` is like `optional(nullable(...))`, i.e. returns a "maybe type".
505
-
506
- **Deprecation warning:**
507
-
508
- - `optional(..., /* allowNull */ true)` is now deprecated in favor of `maybe(...)`
509
-
510
- ## v1.8.2
511
-
512
- **Improved error reporting:**
513
-
514
- - Fix bug where empty error branches could be shown in complex either expressions (fixes
515
- #83)
516
-
517
- ## v1.8.1
518
-
519
- - Fix: revert accidentally emitting \$ReadOnlyArray types in array decoders
520
-
521
- ## v1.8.0
522
-
523
- - Drop support for Node 7
524
- - Declare inputted arrays will not be modified (treated as read-only)
525
-
526
- ## v1.7.0
527
-
528
- - Make decoders fully [Flow Strict](https://flow.org/en/docs/strict/) compatible
529
-
530
- ## v1.6.1
531
-
532
- - Upgraded debrief dependency
533
- - Behave better in projects that have Flow's `experimental.const_params` setting turned
534
- on
535
-
536
- ## v1.6.0
537
-
538
- - **New decoders!**
539
- - `exact()` is like `object()`, but will fail if the inputted object contains
540
- superfluous keys (keys that aren't in the object definition).
541
-
542
- ## v1.5.0
543
-
544
- - Collect and report all nested errors in an object() at once (rather than error on the
545
- first error).
546
-
547
- **Breaking:**
548
-
549
- - Remove deprecated `message` argument to `object()`
550
-
551
- ## v1.4.6
552
-
553
- - Add missing documentation
554
-
555
- ## v1.4.5
556
-
557
- - Upgrade second-level dependencies
558
-
559
- ## v1.4.4
560
-
561
- - Declare library to be side effect free (to help optimize webpack v4 builds)
562
- - Upgrade dependencies
563
-
564
- ## v1.4.1
565
-
566
- - Improve internals of the error message serializer (debrief)
567
-
568
- ## v1.4.0
569
-
570
- - **New decoders!**
571
- - `email` validator based on the
572
- [almost perfect email regex](http://emailregex.com/)
573
- - `url` validator for validating HTTPS URLs (most common use case)
574
- - `anyUrl` validator for validating any URL scheme
575
-
576
- ## v1.3.1
577
-
578
- - Fix bug where dates, or arrays (or any other Object subclass) could pass for a record
579
- with merely optional fields.
580
-
581
- ## v1.3.0
582
-
583
- - Much improved error messages! They were redesigned to look great in terminals and to
584
- summarize only the relevant bits of the error message, striking a balance between all
585
- the details and the high level summary.
586
-
587
- ## v1.2.4
588
-
589
- - **New features**:
590
- - `truthy` takes any input and returns whether the value is truthy
591
- - `numericBoolean` takes only numbers as input, and returns their boolean
592
- interpretation (0 = false, non-0 = true)
593
-
594
- ## v1.2.2, v1.2.3
595
-
596
- - **New feature** `mixed` decoder, for unverified pass-thru of any values
597
-
598
- ## v1.2.1
599
-
600
- - **Fix** Expose the following decoders publicly:
601
- - `integer`
602
- - `positiveInteger`
603
- - `positiveNumber`
604
-
605
- ## v1.2.0
606
-
607
- - **New feature** `regex()`, for building custom string decoders
608
- - Tiny tweaks to improve error messages (more structural improvements are on the
609
- roadmap)
610
-
611
- ## v1.1.0
612
-
613
- - Expose pojo() decoder, for plain old objects (with mixed contents)
614
- - Expose poja() decoder, for plain old arrays (with mixed contents)
615
- - Perf: make `tuple2()` decoder lazier
616
-
617
- ## v1.0.1
618
-
619
- - Expose new "either" decoders at the too level
620
-
621
- ## v1.0.0
622
-
623
- - **BREAKING** Removes the old public ("compat") API
624
- - Finalize/settle on public API
625
-
626
- ## v0.1.3
627
-
628
- - Add whole series for either, either3, either4, ..., either9
629
- - Updated dev dependencies
630
-
631
- ## v0.1.2
632
-
633
- - Add `date` decoder, which decodes `Date` instances
634
- - Improve error output detail when throwing errors
635
-
636
- ## v0.1.1
637
-
638
- - Export `g2d()` helper function that can help adoption to new-style APIs by converting
639
- old-style decoders (now called guards) to new-style decoders.
640
-
641
- ## v0.1.0
642
-
643
- - **Breaking change** New API: simplified names, split up decoders from guards. What
644
- used to be called "decoders" in 0.0.x ("things that either return a value or throw a
645
- runtime error") are now called "guards" in 0.1.0. The meaning of the term "decoders"
646
- is now changed to a thing that either is an "Ok" value or an "Err" value.
647
-
648
- To convert to the new API, do this:
649
-
650
- ```javascript
651
- // Old way
652
- import { decodeNumber, decodeObject, decodeString } from 'decoders';
653
-
654
- const decoder = decodeObject({
655
- name: decodeString(),
656
- age: decodeNumber(),
657
- });
658
-
659
- // -------------------------------------------------------------------
660
-
661
- // New way
662
- import { guard, number, object, string } from 'decoders';
663
-
664
- const guard = guard(
665
- object({
666
- name: string,
667
- age: number,
668
- }),
669
- );
670
- ```