- 3a7928c: Customize error messages using a MessageBuilder.
- 42bc4fe: Test Version Packages fix
-
66f5b5d: Match
ZodError
via heuristics instead of relying oninstanceof
.Why? Because we want to ensure that zod-validation-error works smoothly even when multiple versions of zod have been installed in the same project.
- 6b4e8a0: Introduce
fromError
API which is a less strict version offromZodError
- 35a28c6: Add runtime check in
fromZodError
and throw dev-friendlyTypeError
suggesting usage offromError
instead
- 3f5e391: Better error messages for zod.function() types
- 2f1ef27: Bundle code as a single index.js (cjs) or index.mjs (esm) file. Restore exports configuration in package.json.
- 24b773c: Revert package.json exports causing dependant projects to fail
- 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.
-
deb4639: BREAKING CHANGE: Refactor
ValidationError
to acceptErrorOptions
as second parameter.What changed?
Previously,
ValidationError
acceptedArray<ZodIssue>
as 2nd parameter. Now, it acceptsErrorOptions
which contains acause
property. Ifcause
is aZodError
then it will extract the attached issues and expose them overerror.details
.Why?
This change allows us to use
ValidationError
like a native JavaScript Error. For example, we can now do:import { ValidationError } from 'zod-validation-error'; try { // attempt to do something that might throw an error } catch (err) { throw new ValidationError('Something went deeply wrong', { cause: err }); }
How can you update your code?
If you are using
ValidationError
directly, then you need to update your code to passErrorOptions
as a 2nd parameter.import { ValidationError } from 'zod-validation-error'; // before const err = new ValidationError('Something went wrong', zodError.issues); // after const err = new ValidationError('Something went wrong', { cause: zodError });
If you were never using
ValidationError
directly, then you don't need to do anything.
- b084ad5: Add
includePath
option to allow users take control on whether to include the erroneous property name in their error messages.
-
b199ca1: Update
toValidationError()
to return onlyValidationError
instancesThis change only affects users of
toValidationError()
. The method was previously returningError | ValidationError
and now returns onlyValidationError
.
- 82b7739: Expose errorMap property to use with zod.setErrorMap() method
- 8893d16: Expose fromZodIssue method
- 218da5f: fix: casing typo of how zod namespace was referenced
- 8ccae09: Added exports of types for parameters of fromZodError function
- 449477d: Switch to using npm instead of yarn. Update node requirement to v.16+
-
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 readsError X at index 1
.Likewise, previously a validation error at property "_" would yield
Error X at "["_"]"
. Now it yieldsError X at "\*"
which reads much better.
- b693f52: Handle unicode and special-character identifiers
- b868741: Fix broken links in API docs
- 90b2f83: Update ZodValidationError to behave more like a native Error constructor. Make options argument optional. Add name property and define toString() method.
- a2e5322: Ensure union errors do not output duplicate messages
- 9c4c4ec: Make union errors more detailed
- 59ad8df: Expose isValidationErrorLike type-guard
- fa81c9b: Drop SWC; Fix ESM export
- 7f420d1: Update build and npm badges on README.md
- fde2f50: update dependency in package json so the user does not have to manually install it, will be installed on package install.
- 67336ac: Enable automatic release to npm
- fcda684: Initial functionality