Skip to content

v8.4.0

Pre-release
Pre-release

Choose a tag to compare

@DZakh DZakh released this 17 Oct 07:22
· 382 commits to main since this release

TS API Features

Shorthand syntax for S.schema

const loginSchema = S.schema({
  email: S.email(S.string),
  password: S.stringMinLength(S.string, 8),
});

It's going to replace S.object in V9.

Shorthand syntax for S.union

const shapeSchema = S.union([
  {
    kind: "circle" as const,
    radius: S.number,
  },
  {
    kind: "square" as const,
    x: S.number,
  },
  {
    kind: "triangle" as const,
    x: S.number,
    y: S.number,
  },
]);

Added function-based operation instead of method-based

  • parseWith
  • parseAsyncWith
  • convertWith
  • convertToJsonStringWith
  • assertWith

They throw exceptions by default. You can use the S.safe and S.safeAsync to turn them into result objects.

Deprecations in favor of a new name

  • S.variant -> S.to
  • S.assertAnyWith -> S.assertWith

Temporary Regressions/Breaking changes

  • S.to/S.variant doesn't allow to destructure tuples anymore
  • s.flatten stopped working with S.schema

Reverse conversion (serializing) improvement

Now, it's possible to convert back to object schemas where a single field is used multiple times.

Bug Fix

Fix parsing of a tuple nested inside of an object schema.

Full Changelog: v8.3.0...v8.4.0