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