zod-validation-error 是一个用于处理 Zod 验证错误消息的开源库。Zod 是一个 TypeScript 优先的验证库,而 zod-validation-error 则旨在简化从 Zod 验证错误中提取和格式化错误消息的过程。这个库可以将 Zod 的验证错误转换为用户友好的可读消息,同时保留原始的错误详情,方便开发者进行调试和分析。 2. 可能
import{zaszod}from'zod';import{fromError}from'zod-validation-error';// create zod schemaconstzodSchema=zod.object({id:zod.number().int().positive(),email:zod.string().email(),});// parse some invalid valuetry{zodSchema.parse({id:1,email:'foobar',// note: invalid email});}catch(er...
import { z as zod } from 'zod'; const { ValidationError } = require('zod-validation-error'); const error = new ValidationError('foobar', { cause: new zod.ZodError([ { code: 'invalid_string', message: 'Invalid email', path: ['email'], validation: 'email', }, ]), }); console...
{ "name": "zod-validation-error", "version": "3.4.0", "description": "Wrap zod validation errors in user-friendly readable messages", "keywords": [ "zod", "error", "validation" ], "license": "MIT", "repository": { "type": "git", "url": "git://github.com/causaly/zod-valid...
Bumps zod-validation-error from 3.3.1 to 3.4.0. Release notes Sourced from zod-validation-error's releases. v3.4.0 Minor Changes 3a7928c: Customize error messages using a MessageBuilder. Cha...
Hi! This library is great, but there's a helper I find myself needing to write myself for it when I use it - a check to see if an error is a zod error in the first place. This will help with code like this where we don't actually know if...
What this PR does / why we need it: Before this fix, we were simply passing through the default error messages generated by Zod when validation failed. This resulted in JSON-like error messages when a Zod schema validation error happened. ...
issue: when using zod for date validation, an error object is not created on change, even though the mode is set to "onChange” #12294 Closed 1 task done crypt0box opened this issue Oct 3, 2024· 5 comments · Fixed by #12295· May be fixed by Opetushallitus/jod-yksilo-ui#259 ...
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...