Skip to content

Releases: causaly/zod-validation-error

v3.4.0

16 Sep 06:44
Compare
Choose a tag to compare

Minor Changes

  • 3a7928c: Customize error messages using a MessageBuilder.

v3.3.1

01 Aug 12:14
62e6826
Compare
Choose a tag to compare

Patch Changes

  • 42bc4fe: Test Version Packages fix

v3.3.0

10 May 06:29
Compare
Choose a tag to compare

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 installed in the same project.

v3.2.0

23 Apr 12:15
Compare
Choose a tag to compare

Minor Changes

  • 6b4e8a0: Introduce fromError API which is a less strict version of fromZodError
  • 35a28c6: Add runtime check in fromZodError and throw dev-friendly TypeError suggesting usage of fromError instead

v3.1.0

04 Apr 16:34
edb2b32
Compare
Choose a tag to compare

Minor Changes

  • 3f5e391: Better error messages for zod.function() types

v3.0.3

28 Feb 07:51
Compare
Choose a tag to compare

Patch Changes

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

v3.0.2

13 Feb 08:10
Compare
Choose a tag to compare

Patch Changes

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

v3.0.1

12 Feb 08:44
Compare
Choose a tag to compare

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.

v3.0.0

16 Jan 09:38
Compare
Choose a tag to compare

Major Changes

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

    What changed?

    Previously, ValidationError accepted Array<ZodIssue> as 2nd parameter. Now, it accepts ErrorOptions which contains a cause property. If cause is a ZodError then it will extract the attached issues and expose them over error.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 pass ErrorOptions 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.

v2.1.0

31 Oct 07:42
Compare
Choose a tag to compare

Minor Changes

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