Changelog

All notable changes to @causaly/zod-validation-error will be documented here.

5.0.0

Note: This is a major release due to a deliberate change in how error messages are formatted to improve consistency. Otherwise, it is 100% compatible with the previous version. If you don't strictly assert against the exact wording of the error messages in your test suites, you can safely upgrade to v5.0.0 without any code changes.

Major Changes

  • 2c5a3c4: Change error messages to consistently follow the expected <expectation>, received <realization> format (breaking change).

Minor Changes

  • 2c5a3c4: Conditionally report input values in the error message based on the new reportInput option.

3.5.4

Patch Changes

  • 6640d99: Add [email protected] compatibility, which was inadvertently broken by adopting the zod/v3 import paths.

4.0.2

Patch Changes

  • 6fd928f: Improve handling for zod.discriminatedUnion errors.

4.0.1

Patch Changes

  • f8b7c44: Handle no path property in "invalid_union" by @MiaInturi.

4.0.0

Major Changes

  • 9be31d2: Make v4 the default export of zod-validation-error.
  • b979890: Add support for zod v4 as a peer dependency.
  • 3bf9e78: Update the API to fundamentally separate between internal Error Mapping and external Message Building.

3.5.2

Patch Changes

  • 3809f85: Include paths of sub-issues belonging to a union.

3.5.1

Patch Changes

  • e7713d5: Add compatibility with older node versions and module-resolution strategies + improve documentation.

3.5.0

Minor Changes

  • bf72012: Add foundational support for zod v4.

3.4.1

Patch Changes

  • 94d5f3b: Bump zod to v.3.24.4 in package.json as dev + peer dependency.

3.4.0

Minor Changes

  • 3a7928c: Customize error messages using a MessageBuilder.

3.3.1

Patch Changes

  • 42bc4fe: Test Version Packages fix.

3.3.0

Minor Changes

  • 66f5b5d: Match ZodError via heuristics instead of relying on instanceof.

Why? Because we want to ensure that zod-validation-error works smoothly even when multiple versions of zod have been inadvertently installed in the same project due to monorepo or dependency deduplication quirks.

3.2.0

Minor Changes

  • 6b4e8a0: Introduce fromError API which acts as a less strict, more forgiving version of fromZodError.
  • 35a28c6: Add runtime checks in fromZodError and throw a dev-friendly TypeError suggesting usage of fromError instead if misused.

3.1.0

Minor Changes

  • 3f5e391: Generate significantly better error messages for zod.function() types.

3.0.3

Patch Changes

  • 2f1ef27: Bundle code as a single index.js (cjs) or index.mjs (esm) file. Restore exports configuration in package.json.

3.0.2

Patch Changes

  • 24b773c: Revert package.json exports causing dependant projects to fail.

3.0.1

Patch Changes

  • 3382fbc: 1. Fix issue with ErrorOptions not being found in earlier-to-es2022 typescript configs. 2. Add exports definition to package.json to help bundlers (e.g., rollup) identify the right module to use.

3.0.0

Major Changes

  • deb4639: BREAKING CHANGE: Refactor ValidationError to accept ErrorOptions as second parameter.

What changed? Previously, ValidationError accepted Array<ZodIssue> as a 2nd parameter. Now, it accepts ErrorOptions which contains a cause property. If cause is a ZodError, it extracts the attached issues and exposes them over error.details.

Why? This change allows us to use ValidationError identically to a native JavaScript Error.

2.1.0

Minor Changes

  • b084ad5: Add includePath option to allow users to take control of whether to include the erroneous property name in their error messages.

2.0.0

Major Changes

  • b199ca1: Update toValidationError() to return strictly ValidationError instances. This change only affects users of toValidationError(). The method was previously returning Error | ValidationError and now returns only ValidationError.

1.5.0

Minor Changes

  • 82b7739: Expose errorMap property to use directly with the zod.setErrorMap() method.

1.4.0

Minor Changes

  • 8893d16: Expose fromZodIssue method.

1.3.1

Patch Changes

  • 218da5f: fix: casing typo of how the zod namespace was referenced.

1.3.0

Minor Changes

  • 8ccae09: Added exports of types for parameters of the fromZodError function.

1.2.1

Patch Changes

  • 449477d: Switch to using npm instead of yarn. Update node requirement to v.16+.

1.2.0

Minor Changes

  • f3aa0b2: Better handling for single-item paths. Given a validation error at array position 1, the error output would read Error X at "[1]". After this change, the error output reads Error X at index 1.

1.1.0

Minor Changes

  • b693f52: Handle unicode and special-character identifiers gracefully.

1.0.0

Major Changes

  • 90b2f83: Update ZodValidationError to behave identically to a native Error constructor. Make options argument optional. Add name property and define a standard toString() method.

0.3.2

Patch Changes

  • a2e5322: Ensure union errors do not output duplicate messages.

0.3.1

Patch Changes

  • 9c4c4ec: Make union errors more detailed.

0.3.0

Minor Changes

  • 59ad8df: Expose isValidationErrorLike heuristic type-guard.

0.2.1

Patch Changes

  • 7f420d1: Update build and npm badges on README.md.

0.2.0

Minor Changes

  • fde2f50: Update dependency in package.json so the user does not have to manually install it; it will be installed on package install.

0.1.0

Minor Changes

  • fcda684: Initial core functionality and release.