-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[Zod 4] RFC: ZodIssue
formats
#3713
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
colinhacks
wants to merge
73
commits into
main
Choose a base branch
from
v4-rfc-issues
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* feat: supports optional tuple elements * fix: adds type assertions for optional elements in tuple * fix: minItems equals num elements before only optionals * fix: adds findMinItems() for tuple.minItems * Build deno --------- Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
This reverts commit 32e05cf.
* feat: implement primitive array uniqueness * chore: update yarn.lock * feat: implement array of complex objects uniqueness * chore: rollback yarn.lock * refactor: minor update _arrayUnique * chore: minor change yarn.lock * feat: implement custom message support * feat: add showDuplicates param * chore: TS types update * chore: TS types II * refactor: ArrayMessageFunction * refactor: simplify array uniqueness implementation * docs: add documentation for array uniqueness * Regen lock * Fix readme --------- Co-authored-by: Frederic Woelffel <hello@fwoelffel.me> Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
* feat(string): add jwt validator type Validate string in JWT format. NOT validate signature * test(string): add tests to validate jwt parse Validate all possibilities for validation function * docs(main): update main README Add z.string().jwt() to String validations list * fix(types): remove forgotten console.log * refactor(types-string): replace Buffer.from method for atob into JWT validation atob method is compatible with Node and modern browsers * fix(types-string): header property was misspelled Property is 'typ' and not 'type' * feat(types-string): add algorithm option to jwt Can pass a algorithm option to jwt method to check the algorithm of token. If not pass, no check is done for alg. * test(string): update tests to check jwt method Fix tests with false positive and add tests to check algorithm validation * docs(README): update readme.md Add info that jwt method accepts algorithm as option * Tweak API and docs * Fix tests --------- Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
* Add test for stricter UUID * Add test for stricter UUID (mirror in Deno tests) * Add test for separate guid string validator * Update UUID to follow RFC4122 strictly * Add guid string validator * Change test.each to array.forEach for automatic deno build * Add isGUID method * Add other uuid regexes * Update tests --------- Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
* fix: tree shake named exports * docs: explain why wrapper functions * fix: make coerce tree shakeable * fix: make util tree shakeable * Fix merge conflicts --------- Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
* feat: Allow passing custom message to literal Fixes #2974 Uses a message key instead of "invalid_xx" key - because those are only used for required and invalid type using a message key is more in line with other checks * Remove lib --------- Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
* Add z.string().json(...) helper * use parseAsync + await expect(...).rejects * make it work in deno * Add overload --------- Co-authored-by: Misha Kaletsky <mmkal@users.noreply.github.com> Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
* Add `@web-std/file` dev dependency * Add ZodFile * Use fallback interfaces * Fix test * Fix tests * .accept() -> .type() * .filename -> .name --------- Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
* feat: add support for KSUIDs * chore: remove yarn lock from pr * chore: add yarn lock from current master
* Allow undefined values in record, similar to object. * Clean unnecessary logic * Update `mergeObjectAsync` to support `alwaysSet` like `mergeObjectSync` * Use existing type * Update tests * Clean up --------- Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
…name and forbid TLD without subdomains (#3049)
* Update README_ZH.md (#3433) fix Demo -> Deno * Clean up code, fix build/test * Write docs * Fix rollup build * Fix setup-deno * Add types field * Fix types * Use globalThis check * Add _tag to ZodError * Comments * Add better tests * suggestions for effect plugin (#3449) * Updates * Move to .effect.parse() * Bind this in getter * Clean up --------- Co-authored-by: sdshaoda <21106848+sdshaoda@users.noreply.github.com> Co-authored-by: Tim <hello@timsmart.co>
* v3.23.6 * Add copper * Create fa.ts * Update ERROR_HANDLING.md * Rebase * Update readme --------- Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
* `ZodTemplateLiteral` initial commit. * `ZodTemplateLiteral` regex building & parsing. * add `ZodTemplateLiteral` @ firstparty.test. * some inference test cases for `ZodTemplateLiteral`. * append to regexString instead of rebuild @ `ZodTemplateLiteral.addPart`. * initial parse tests for `ZodTemplateLiteral`. * "internalize" `addPart`, add `addLiteral` & `addInterpolatedPosition`. * move `ZodTemplateLiteral` unit test cases and minor fixes. * minor fixes, more tests. * minor fixes, more tests pt. 2. * more tests pt. 3. * more tests pt. 4. * add `ZodTemplateLiteral` README.md section. * add a simpler example @ ZodTemplateLiteral docs. * add regex limitations remark. * allow coercion to ZodTemplateLiteral. * minor readability pass on number stuff @ ZodTemplateLiteral. * add ZodBranded support @ ZodTemplateLiteral. * support ZodAny @ ZodTemplateLiteral. * support ZodAny @ ZodTemplateLiteral. * minor README.md changes. * add ZodTemplateLiteral coerce test. * add ZodTemplateLiteral custom errors for unsupported stuff. * add ZodTemplateLiteral custom errors for unsupported stuff. pt. 2. * add ZodTemplateLiteral custom errors for unsupported stuff pt. 3. Co-authored-by: Max Arturo <5713763+maxArturo@users.noreply.github.com> * use official MDN way of escaping for regex. Co-authored-by: Max Arturo <5713763+maxArturo@users.noreply.github.com> * explicitly state exponent notation is not supported @ ZodTemplateLiteral Co-authored-by: Max Arturo <5713763+maxArturo@users.noreply.github.com> * add missing `.toThrow()` @ ZodTemplateLiteral tests. Co-authored-by: Max Arturo <5713763+maxArturo@users.noreply.github.com> * explicitly state `.trim()` is not supported @ ZodTemplateLiteral. Co-authored-by: Max Arturo <5713763+maxArturo@users.noreply.github.com> * fix mongodb connection string example and tests. * add measurment example from README to ZodTemplateLiteral tests. * extract ZodTemplateLiteral errors to ZodError.ts Co-authored-by: Max Arturo <5713763+maxArturo@users.noreply.github.com> * add `z.string().cuid2()` support. * add support for new regex based string checks. * rename to `.interpolated` & `.literal`. * rename to `.interpolated` & `.literal` pt. 2. * handle case insensitive regexes. * prettier the readme. * Update cuid2 test * Switch to z.literal.template, update tests, update eslint, bump TS to 5.0+ * Empty * Update readme * Update readme * Clean up types --------- Co-authored-by: Max Arturo <5713763+maxArturo@users.noreply.github.com> Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
…3487) * wip * INVALID -> ZodFailure, fix input issue * Add new benchmarks * Switch away from Ok<T> wrapper * ZodString optimizations * playground.mts * Remove ZodString opt, update benchmarks * Detect promises in parsing instead of using ctx.async * Fix tests * Switch benchmarks to tinybench * Update benchmarks * Updates --------- Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
* Added e164 validation * cleanup and missing files * added documentation * Build deno * Fix tests --------- Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
* separate typecheck from runtime testing * Fix tests * Fix typechecking * Remove failures * Test on latest and next TS only --------- Co-authored-by: Misha Kaletsky <mmkal@users.noreply.github.com> Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
* 3.23.5 * Experiments * WIP * WIP * Ignore tshy * Fix type errors * Fix tsconfigs
* Update benchmarks to ESM * Undo packagejson changes
* WIP * Add condition * Fix formatting * Format * Build
✅ Deploy Preview for guileless-rolypoly-866f8a ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
ZodIssue
formats
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Old formats:
https://github.com/colinhacks/zod/blob/v4-rfc-issues/rfcs/v4-issue-formats/old_formats.ts
New formats: https://github.com/colinhacks/zod/blob/v4-rfc-issues/rfcs/v4-issue-formats/new_formats.ts
Conceptually speaking these are the major changes:
ZodIssue
is a 2-level discriminated union. The first level discriminates oncode
:invalid_type
,invalid_string
m etc. For eachcode
, there are sub-issues that are discriminated with thecheck
field.invalid_union
,invalid_literal
,invalid_enum_value
intoinvalid_type
too_big
andtoo_small
across the specific types for which they are defined:invalid_string
,invalid_array
, etc.invalid_string
) there is an additional layer of discrimination using thecheck
key. Instead of a top-levelZodNotMultipleOfIssue
, this is now acheck: "multiple_of"
withincode: "invalid_string"
.invalid_arguments
,invalid_return_type
,invalid_discriminator_value
as these issues are specific to types that will be removed in Zod 4.