Skip to content

Latest commit

 

History

History
138 lines (74 loc) · 5.73 KB

File metadata and controls

138 lines (74 loc) · 5.73 KB

@badrap/valita

0.4.6

Patch Changes

  • 7c42103 Thanks @jviide! - Publish npm packages using trusted publishing

0.4.5

Patch Changes

  • d312e6d Thanks @jviide! - feat: always normalize custom errors

    Custom errors listed in issue lists (ValitaError.issue and ValitaResult.issue) are now always normalized to match the type { code: "custom_error", path: (string | number)[], message?: string | undefined }.

  • e66a42e Thanks @jviide! - Allow passing a type to .chain()

    The .chain() method of types now accepts other types as-is:

    v.string() // Accept strings as input,
      .map((s) => Number(s)) // then parse the strings to numbers,
      .chain(v.literal(1)); // and ensure that the parsed number is 1.

    The parsing mode is propagated to the chained type:

    const example = v.unknown().parse(v.object({ a: v.number() }));
    
    example.parse({ a: 1, b: 2 }, { mode: "strip" });
    // { a: 1 }

0.4.4

Patch Changes

  • b9d9c30 Thanks @jviide! - Add support for .nullable(() => x)

    The .nullable() method now supports default value functions_similarly to .optional().

0.4.3

Patch Changes

0.4.2

Patch Changes

  • c648586 Thanks @jviide! - Include an array of sub-issues in "invalid_union" issues

0.4.1

Patch Changes

0.4.0

Minor Changes

0.3.16

Patch Changes

  • 59b89be Thanks @arv for reporting this! - Revert changes since v0.3.12 as they were backwards incompatible

0.3.15

Patch Changes

0.3.14

Patch Changes

0.3.12

Patch Changes

  • 8aaad50 Thanks @jviide! - Mark .optional(() => ...) as non-experimental and recommend it over the now-deprecated .default(x)

0.3.11

Patch Changes

  • f78c082 Thanks @jviide! - Add experimental support for .optional(() => x)

    The .optional() method now supports default value functions for replacing undefined and missing values from the input and wrapped validator. The functionality is similar to .default(x), except that defaultFn has to be a function and is executed for each validation run. This allows patterns like the following:

    const Item = v.object({ id: v.string() });
    
    const Items = v.array(Item).optional(() => []);

    This avoids a common pitfall with using .default([]) for the same pattern. As the newly created empty arrays are not shared, mutating them is safe(r) as it doesn't affect other validation outputs.

    This feature is marked experimental for the time being.

0.3.10

Patch Changes

  • 43513b6 Thanks @jviide! - Add support for variadic tuple types

    Tuple and array types now have a new method, .concat() that can be used to create variadic tuple types.

  • 43513b6 Thanks @jviide! - Make v.array() a shorthand for v.array(v.unknown())

0.3.9

Patch Changes

0.3.8

Patch Changes

  • d2f85db Thanks @jviide! - Fix release automation, name scripts bump/release instead of version/publish

0.3.7

Patch Changes