Skip to content

Releases: nvie/decoders

v2.9.1

11 Mar 14:40

Choose a tag to compare

  • Fix sized() error messages to use singular "item"/"char" when count is 1
  • Tweak nonEmptyArray() error message (from "Must be non-empty array" to "Must have at least 1 item")

v2.9.0

08 Mar 21:09

Choose a tag to compare

Breaking!

  • Rename Decoder.then()Decoder.chain() to avoid confusion with Promises (custom thenables)

New APIs:

  • New: sized(decoder, {min?, max?, size?}) utility for adding length validation to strings, arrays, and sets.
  • New: min(min, decoder?), max(max, decoder?), and between(min, max, decoder?) utilities for adding inclusive numeric range validation. The decoder defaults to number if omitted.
  • New: urlString decoder, which is like url, but returns a string instead of a URL instance.

Changes:

  • Rename date decoders for clarity:
    • iso8601isoDate (iso8601 will be kept as alias)
    • dateStringisoDateString (deprecated, will be removed in 3.x)
    • datelikeflexDate (deprecated, will be removed in 3.x)
  • Cleaner error messages for flexDate and url decoders
  • Add missing top-level type exports for annotations
  • Improve deeper tree-shaking support (thanks @EskiMojo14!)

v2.9.0-pre.5

06 Mar 13:04

Choose a tag to compare

v2.9.0-pre.5 Pre-release
Pre-release

Breaking!

  • Rename Decoder.then()Decoder.chain() to avoid confusion with Promises (custom
    thenables)

New APIs:

  • New: sized(decoder, {min?, max?, size?}) utility for adding length validation to
    strings, arrays, and sets.
  • New: min(min, decoder?), max(max, decoder?), and between(min, max, decoder?)
    utilities for adding inclusive numeric range validation. The decoder defaults to
    number if omitted.
  • New: urlString decoder, which is like url, but returns a string instead of a URL
    instance.

Changes:

  • Rename date decoders for clarity:
    • iso8601isoDate (iso8601 will be kept as alias)
    • dateStringisoDateString (deprecated, will be removed in 3.x)
    • datelikeflexDate (deprecated, will be removed in 3.x)
  • Cleaner error messages for flexDate and url decoders
  • Add missing top-level type exports for annotations

v2.8.0

22 Feb 13:42

Choose a tag to compare

  • New: anything is now an alias for unknown, which might be more readable in some contexts
  • In error output, display promise, bigint, and any other unknown values (instead of '???')
  • Export some internally used utilities are generally useful:
    • isDate(value)
    • isDecoder(value)
    • isPlainObject(value)
    • isPromiseLike(value)
  • Drop previously deprecated decoders:
    • dict() (prefer record())
    • hardcoded() (prefer always())
    • maybe() (prefer nullish())
    • mixed (prefer unknown)
    • set() (prefer setFromArray())
  • Drop support for Node 18 and below (they will likely still work, but are no longer tested)
  • Export isDecoder(value) helper

v2.7.5

02 Sep 19:47

Choose a tag to compare

  • Fixes for url decoder:
    • Sanitizes (legal) empty user/passwords
    • Accepts any char as part of username/password
    • Accepts a wider range of protocol lengths, e.g. now also recognizes at:// and postgresql:// URLs

v2.7.4

02 Sep 16:05

Choose a tag to compare

Bad release, please use 2.7.5 instead.

v2.7.3

02 Sep 15:30

Choose a tag to compare

Bad release, please use 2.7.5 instead.

v2.7.2

01 Sep 15:29

Choose a tag to compare

Bad release, please use 2.7.5 instead.

v2.7.1

01 Aug 09:54

Choose a tag to compare

  • Fix: dateString decoder is now properly exported at the top-level
  • Fix: oneOf() decoder now correctly handles undefined constants

v2.7.0

31 Mar 21:38

Choose a tag to compare

  • Add new dateString decoder (see docs)
  • Add new .refineType<SubT>() method (see docs)
  • Reduce peak memory usage of array() decoder