cross-seed 7.0.0-21 → 7.0.0-23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/action.js +7 -8
- package/dist/action.js.map +1 -1
- package/dist/arr.js +2 -2
- package/dist/arr.js.map +1 -1
- package/dist/bencode.d.ts +62 -0
- package/dist/bencode.js +248 -0
- package/dist/bencode.js.map +1 -0
- package/dist/clients/Deluge.d.ts +5 -10
- package/dist/clients/Deluge.js +115 -89
- package/dist/clients/Deluge.js.map +1 -1
- package/dist/clients/QBittorrent.d.ts +3 -0
- package/dist/clients/QBittorrent.js +43 -30
- package/dist/clients/QBittorrent.js.map +1 -1
- package/dist/clients/RTorrent.d.ts +3 -2
- package/dist/clients/RTorrent.js +120 -41
- package/dist/clients/RTorrent.js.map +1 -1
- package/dist/clients/TorrentClient.d.ts +3 -2
- package/dist/clients/TorrentClient.js +3 -5
- package/dist/clients/TorrentClient.js.map +1 -1
- package/dist/clients/Transmission.d.ts +1 -0
- package/dist/clients/Transmission.js +90 -40
- package/dist/clients/Transmission.js.map +1 -1
- package/dist/clients/qbittorrent-version.d.ts +6 -0
- package/dist/clients/qbittorrent-version.js +11 -0
- package/dist/clients/qbittorrent-version.js.map +1 -0
- package/dist/clients/scgi.d.ts +14 -0
- package/dist/clients/scgi.js +111 -0
- package/dist/clients/scgi.js.map +1 -0
- package/dist/cmd.js +1 -1
- package/dist/cmd.js.map +1 -1
- package/dist/configuration.js +49 -9
- package/dist/configuration.js.map +1 -1
- package/dist/constants.d.ts +10 -0
- package/dist/constants.js +12 -2
- package/dist/constants.js.map +1 -1
- package/dist/dataFiles.d.ts +1 -0
- package/dist/dataFiles.js +252 -60
- package/dist/dataFiles.js.map +1 -1
- package/dist/db.js +8 -4
- package/dist/db.js.map +1 -1
- package/dist/decide.js +8 -8
- package/dist/decide.js.map +1 -1
- package/dist/devLogin.js.map +1 -1
- package/dist/diff.js.map +1 -1
- package/dist/indexers.js +5 -4
- package/dist/indexers.js.map +1 -1
- package/dist/inject.js +5 -5
- package/dist/inject.js.map +1 -1
- package/dist/jobs.js +2 -1
- package/dist/jobs.js.map +1 -1
- package/dist/libraryInventory.d.ts +176 -0
- package/dist/libraryInventory.js +701 -0
- package/dist/libraryInventory.js.map +1 -0
- package/dist/logger.js +7 -5
- package/dist/logger.js.map +1 -1
- package/dist/migrations/09-clientAndDataSearchees.js +1 -0
- package/dist/migrations/09-clientAndDataSearchees.js.map +1 -1
- package/dist/migrations/17-api-key-settings-json.js +3 -1
- package/dist/migrations/17-api-key-settings-json.js.map +1 -1
- package/dist/migrations/18-library-inventory.d.ts +9 -0
- package/dist/migrations/18-library-inventory.js +48 -0
- package/dist/migrations/18-library-inventory.js.map +1 -0
- package/dist/migrations/19-library-files.d.ts +9 -0
- package/dist/migrations/19-library-files.js +26 -0
- package/dist/migrations/19-library-files.js.map +1 -0
- package/dist/migrations/migrations.d.ts +12 -5
- package/dist/migrations/migrations.js +5 -1
- package/dist/migrations/migrations.js.map +1 -1
- package/dist/parseTorrent.d.ts +1 -1
- package/dist/parseTorrent.js +18 -4
- package/dist/parseTorrent.js.map +1 -1
- package/dist/pipeline.js +12 -11
- package/dist/pipeline.js.map +1 -1
- package/dist/problems/linking.js +1 -1
- package/dist/problems/linking.js.map +1 -1
- package/dist/problems.js +2 -1
- package/dist/problems.js.map +1 -1
- package/dist/pushNotifier.js +10 -9
- package/dist/pushNotifier.js.map +1 -1
- package/dist/routes/baseApi.d.ts +8 -0
- package/dist/routes/baseApi.js +26 -52
- package/dist/routes/baseApi.js.map +1 -1
- package/dist/routes/devLogin.js +1 -0
- package/dist/routes/devLogin.js.map +1 -1
- package/dist/routes/indexerApi.js +1 -0
- package/dist/routes/indexerApi.js.map +1 -1
- package/dist/routes/staticFrontendPlugin.js +1 -0
- package/dist/routes/staticFrontendPlugin.js.map +1 -1
- package/dist/searchee.d.ts +14 -2
- package/dist/searchee.js +26 -9
- package/dist/searchee.js.map +1 -1
- package/dist/services/indexerService.js +8 -2
- package/dist/services/indexerService.js.map +1 -1
- package/dist/startup.d.ts +1 -0
- package/dist/startup.js +11 -4
- package/dist/startup.js.map +1 -1
- package/dist/torrent.js +302 -115
- package/dist/torrent.js.map +1 -1
- package/dist/torznab.d.ts +2 -2
- package/dist/torznab.js +15 -14
- package/dist/torznab.js.map +1 -1
- package/dist/trpc/routers/auth.js +1 -1
- package/dist/trpc/routers/auth.js.map +1 -1
- package/dist/trpc/routers/clients.js +8 -13
- package/dist/trpc/routers/clients.js.map +1 -1
- package/dist/trpc/routers/index.d.ts +51 -50
- package/dist/trpc/routers/index.js +2 -2
- package/dist/trpc/routers/index.js.map +1 -1
- package/dist/trpc/routers/jobs.js +1 -1
- package/dist/trpc/routers/jobs.js.map +1 -1
- package/dist/trpc/routers/library.d.ts +50 -0
- package/dist/trpc/routers/library.js +85 -0
- package/dist/trpc/routers/library.js.map +1 -0
- package/dist/trpc/routers/logs.js +6 -5
- package/dist/trpc/routers/logs.js.map +1 -1
- package/dist/trpc/routers/settings.js +78 -21
- package/dist/trpc/routers/settings.js.map +1 -1
- package/dist/trpc/routers/stats.d.ts +1 -0
- package/dist/trpc/routers/stats.js +11 -5
- package/dist/trpc/routers/stats.js.map +1 -1
- package/dist/userAuth.js +1 -1
- package/dist/userAuth.js.map +1 -1
- package/dist/utils/background.d.ts +7 -0
- package/dist/utils/background.js +14 -0
- package/dist/utils/background.js.map +1 -0
- package/dist/utils/logWatcher.js +3 -2
- package/dist/utils/logWatcher.js.map +1 -1
- package/dist/utils.d.ts +11 -1
- package/dist/utils.js +47 -8
- package/dist/utils.js.map +1 -1
- package/dist/webui/assets/DeleteOption-DkdJCiOu.js +1 -0
- package/dist/webui/assets/FieldInfo-rcCXc0d-.js +1 -0
- package/dist/webui/assets/Page-CKwSnUie.js +1 -0
- package/dist/webui/assets/array-field-DM2mAVqa.js +1 -0
- package/dist/webui/assets/badge-CLUazitN.js +1 -0
- package/dist/webui/assets/button-DoKPR9Fv.js +1 -0
- package/dist/webui/assets/check-BlfHpqkp.js +1 -0
- package/dist/webui/assets/clients-B5C80D0F.js +1 -0
- package/dist/webui/assets/connect-BM7yGLAl.js +2 -0
- package/dist/webui/assets/createLucideIcon-Cv-_CLkr.js +1 -0
- package/dist/webui/assets/debug-C8d57uIb.js +1 -0
- package/dist/webui/assets/directories-DkJnb01t.js +1 -0
- package/dist/webui/assets/dist-B7BqKb_s.js +1 -0
- package/dist/webui/assets/dist-CXZZv-cf.js +41 -0
- package/dist/webui/assets/dist-ChMQZgJB.js +1 -0
- package/dist/webui/assets/dist-DQ6Xm99Z.js +1 -0
- package/dist/webui/assets/duration-field-w-qiOS_S.js +1 -0
- package/dist/webui/assets/general-2HmkyF5T.js +1 -0
- package/dist/webui/assets/health-D6tv4ioy.js +1 -0
- package/dist/webui/assets/index-NlorOk2I.js +11 -0
- package/dist/webui/assets/index-UQKt4Igp.css +2 -0
- package/dist/webui/assets/input-BggK3IOz.js +1 -0
- package/dist/webui/assets/jobs-Do8vAIqy.js +1 -0
- package/dist/webui/assets/library-B1r1nAY-.js +1 -0
- package/dist/webui/assets/loader-circle-D988WNxu.js +1 -0
- package/dist/webui/assets/logs-_rm8bxf-.js +1 -0
- package/dist/webui/assets/number-field-CeKyqI7R.js +1 -0
- package/dist/webui/assets/react-dom-DtIef6y6.js +1 -0
- package/dist/webui/assets/required-indicator-Ba9NOQEP.js +1 -0
- package/dist/webui/assets/routes-Djgf7dZI.js +1 -0
- package/dist/webui/assets/search-DGY0ui92.js +1 -0
- package/dist/webui/assets/select-BzZ418Yt.js +1 -0
- package/dist/webui/assets/select-field-DsBowTDT.js +1 -0
- package/dist/webui/assets/settings-B4G8vHXc.js +1 -0
- package/dist/webui/assets/sidebar-Qy-rYdhU.js +5 -0
- package/dist/webui/assets/submit-button-Bx2Dvr03.js +1 -0
- package/dist/webui/assets/switch-CttdmVGp.js +1 -0
- package/dist/webui/assets/switch-field-p-JPVVvW.js +1 -0
- package/dist/webui/assets/table-Bs6CQscS.js +1 -0
- package/dist/webui/assets/{test-tube-CbcievIk.js → test-tube-DD9Yz2bZ.js} +1 -1
- package/dist/webui/assets/text-field-B0a3dEGb.js +1 -0
- package/dist/webui/assets/time-KFQKyrl-.js +1 -0
- package/dist/webui/assets/trackers-DG-YCaaO.js +7 -0
- package/dist/webui/assets/{trash-D083IWKI.js → trash-PHXIGUCt.js} +1 -1
- package/dist/webui/assets/use-settings-form-submit-CDmMUcwW.js +57 -0
- package/dist/webui/assets/useSelector-BoN-mufS.js +2 -0
- package/dist/webui/assets/utils-P-unlvb4.js +1 -0
- package/dist/webui/assets/with-selector-fbK2t2oY.js +1 -0
- package/dist/webui/index.html +12 -14
- package/node_modules/@cross-seed/shared/dist/tsconfig.tsbuildinfo +1 -1
- package/node_modules/@cross-seed/shared/package.json +6 -2
- package/node_modules/zod/README.md +30 -20
- package/node_modules/zod/compile.cjs +96 -0
- package/node_modules/zod/compile.d.cts +1 -0
- package/node_modules/zod/compile.d.ts +1 -0
- package/node_modules/zod/compile.js +52 -0
- package/node_modules/zod/index.cjs +21 -2
- package/node_modules/zod/index.d.cts +1 -2
- package/node_modules/zod/index.d.ts +1 -2
- package/node_modules/zod/index.js +5 -2
- package/node_modules/zod/locales/index.cjs +19 -0
- package/node_modules/zod/locales/package.json +2 -1
- package/node_modules/zod/mini/index.cjs +19 -0
- package/node_modules/zod/mini/package.json +2 -1
- package/node_modules/zod/package.json +20 -8
- package/node_modules/zod/src/compile.ts +56 -0
- package/node_modules/zod/src/index.ts +5 -2
- package/node_modules/zod/src/v3/ZodError.ts +22 -12
- package/node_modules/zod/src/v3/helpers/errorUtil.ts +1 -1
- package/node_modules/zod/src/v3/tests/all-errors.test.ts +3 -3
- package/node_modules/zod/src/v3/tests/error.test.ts +35 -0
- package/node_modules/zod/src/v3/tests/intersection.test.ts +18 -0
- package/node_modules/zod/src/v3/tests/language-server.test.ts +1 -2
- package/node_modules/zod/src/v3/tests/object.test.ts +8 -11
- package/node_modules/zod/src/v3/tests/partials.test.ts +3 -3
- package/node_modules/zod/src/v3/tests/readonly.test.ts +0 -80
- package/node_modules/zod/src/v3/tests/string.test.ts +6 -0
- package/node_modules/zod/src/v3/types.ts +5 -5
- package/node_modules/zod/src/v4/classic/checks.ts +1 -0
- package/node_modules/zod/src/v4/classic/compat.ts +26 -18
- package/node_modules/zod/src/v4/classic/deep-partial.ts +76 -0
- package/node_modules/zod/src/v4/classic/errors.ts +60 -45
- package/node_modules/zod/src/v4/classic/external.ts +15 -9
- package/node_modules/zod/src/v4/classic/from-json-schema.ts +389 -88
- package/node_modules/zod/src/v4/classic/in-out.ts +45 -0
- package/node_modules/zod/src/v4/classic/index.ts +2 -2
- package/node_modules/zod/src/v4/classic/iso.ts +2 -72
- package/node_modules/zod/src/v4/classic/parse.ts +16 -10
- package/node_modules/zod/src/v4/classic/schemas.ts +863 -335
- package/node_modules/zod/src/v4/classic/tests/apply.test.ts +27 -0
- package/node_modules/zod/src/v4/classic/tests/array.test.ts +29 -2
- package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +192 -0
- package/node_modules/zod/src/v4/classic/tests/bigint.test.ts +36 -1
- package/node_modules/zod/src/v4/classic/tests/catch.test.ts +328 -0
- package/node_modules/zod/src/v4/classic/tests/codec-examples.test.ts +1 -2
- package/node_modules/zod/src/v4/classic/tests/codec.test.ts +144 -2
- package/node_modules/zod/src/v4/classic/tests/continuability.test.ts +4 -4
- package/node_modules/zod/src/v4/classic/tests/credit-card.test.ts +76 -0
- package/node_modules/zod/src/v4/classic/tests/cyclic-data.test.ts +985 -0
- package/node_modules/zod/src/v4/classic/tests/date.test.ts +30 -0
- package/node_modules/zod/src/v4/classic/tests/datetime.test.ts +31 -17
- package/node_modules/zod/src/v4/classic/tests/deep-partial.test.ts +380 -0
- package/node_modules/zod/src/v4/classic/tests/default-locale.test.ts +32 -0
- package/node_modules/zod/src/v4/classic/tests/default.test.ts +90 -0
- package/node_modules/zod/src/v4/classic/tests/detached-methods.test.ts +221 -0
- package/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +291 -10
- package/node_modules/zod/src/v4/classic/tests/enum.test.ts +20 -0
- package/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +324 -2
- package/node_modules/zod/src/v4/classic/tests/error.test.ts +403 -6
- package/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +743 -10
- package/node_modules/zod/src/v4/classic/tests/function.test.ts +37 -6
- package/node_modules/zod/src/v4/classic/tests/global-config.test.ts +32 -0
- package/node_modules/zod/src/v4/classic/tests/hash.test.ts +1 -2
- package/node_modules/zod/src/v4/classic/tests/iban.test.ts +81 -0
- package/node_modules/zod/src/v4/classic/tests/in-out.test.ts +159 -0
- package/node_modules/zod/src/v4/classic/tests/index.test.ts +23 -4
- package/node_modules/zod/src/v4/classic/tests/instance-footprint.test.ts +319 -0
- package/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +67 -0
- package/node_modules/zod/src/v4/classic/tests/intersection.test.ts +136 -0
- package/node_modules/zod/src/v4/classic/tests/issue-schema.test.ts +215 -0
- package/node_modules/zod/src/v4/classic/tests/jitless-allows-eval.test.ts +39 -0
- package/node_modules/zod/src/v4/classic/tests/lazy.test.ts +36 -1
- package/node_modules/zod/src/v4/classic/tests/literal.test.ts +12 -1
- package/node_modules/zod/src/v4/classic/tests/locales_ka.test.ts +29 -0
- package/node_modules/zod/src/v4/classic/tests/locales_ro.test.ts +24 -0
- package/node_modules/zod/src/v4/classic/tests/map.test.ts +19 -0
- package/node_modules/zod/src/v4/classic/tests/number.test.ts +138 -7
- package/node_modules/zod/src/v4/classic/tests/object.test.ts +378 -12
- package/node_modules/zod/src/v4/classic/tests/optin-ladder.test.ts +235 -0
- package/node_modules/zod/src/v4/classic/tests/optional.test.ts +156 -13
- package/node_modules/zod/src/v4/classic/tests/partial.test.ts +71 -1
- package/node_modules/zod/src/v4/classic/tests/prefault.test.ts +71 -1
- package/node_modules/zod/src/v4/classic/tests/preprocess-types.test.ts +44 -0
- package/node_modules/zod/src/v4/classic/tests/preprocess.test.ts +69 -0
- package/node_modules/zod/src/v4/classic/tests/properties.test.ts +141 -0
- package/node_modules/zod/src/v4/classic/tests/readonly.test.ts +0 -68
- package/node_modules/zod/src/v4/classic/tests/record.test.ts +269 -16
- package/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +126 -1
- package/node_modules/zod/src/v4/classic/tests/redos.test.ts +68 -0
- package/node_modules/zod/src/v4/classic/tests/refine.test.ts +123 -0
- package/node_modules/zod/src/v4/classic/tests/set.test.ts +15 -0
- package/node_modules/zod/src/v4/classic/tests/standard-schema.test.ts +19 -0
- package/node_modules/zod/src/v4/classic/tests/string.test.ts +269 -4
- package/node_modules/zod/src/v4/classic/tests/stringbool.test.ts +18 -0
- package/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +48 -7
- package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +1948 -205
- package/node_modules/zod/src/v4/classic/tests/transform.test.ts +17 -0
- package/node_modules/zod/src/v4/classic/tests/tuple.test.ts +330 -2
- package/node_modules/zod/src/v4/classic/tests/union.test.ts +93 -2
- package/node_modules/zod/src/v4/classic/tests/validate.test.ts +645 -0
- package/node_modules/zod/src/v4/classic/tests/validations.test.ts +2 -2
- package/node_modules/zod/src/v4/core/api.ts +111 -34
- package/node_modules/zod/src/v4/core/checks.ts +120 -147
- package/node_modules/zod/src/v4/core/compile.ts +2322 -0
- package/node_modules/zod/src/v4/core/core.ts +116 -24
- package/node_modules/zod/src/v4/core/doc.ts +17 -9
- package/node_modules/zod/src/v4/core/errors.ts +138 -43
- package/node_modules/zod/src/v4/core/index.ts +3 -0
- package/node_modules/zod/src/v4/core/json-schema-generator.ts +8 -3
- package/node_modules/zod/src/v4/core/json-schema-processors.ts +440 -173
- package/node_modules/zod/src/v4/core/json-schema.ts +2 -1
- package/node_modules/zod/src/v4/core/memoizer.ts +331 -0
- package/node_modules/zod/src/v4/core/parse.ts +167 -53
- package/node_modules/zod/src/v4/core/regexes.ts +50 -16
- package/node_modules/zod/src/v4/core/registries.ts +2 -2
- package/node_modules/zod/src/v4/core/schemas.ts +1219 -531
- package/node_modules/zod/src/v4/core/tests/cached.test.ts +54 -0
- package/node_modules/zod/src/v4/core/tests/compile-differential.test.ts +1004 -0
- package/node_modules/zod/src/v4/core/tests/compile-generative.test.ts +445 -0
- package/node_modules/zod/src/v4/core/tests/compile-global.test.ts +89 -0
- package/node_modules/zod/src/v4/core/tests/compile-off-by-default.test.ts +26 -0
- package/node_modules/zod/src/v4/core/tests/compile-stats.test.ts +34 -0
- package/node_modules/zod/src/v4/core/tests/compile.test.ts +2036 -0
- package/node_modules/zod/src/v4/core/tests/email-regex.test.ts +140 -0
- package/node_modules/zod/src/v4/core/tests/locales/el.test.ts +214 -0
- package/node_modules/zod/src/v4/core/tests/locales/es.test.ts +1 -2
- package/node_modules/zod/src/v4/core/tests/locales/fr.test.ts +72 -0
- package/node_modules/zod/src/v4/core/tests/locales/hr.test.ts +163 -0
- package/node_modules/zod/src/v4/core/tests/locales/parity.test.ts +42 -0
- package/node_modules/zod/src/v4/core/tests/locales/tg.test.ts +85 -0
- package/node_modules/zod/src/v4/core/tests/locales/tk.test.ts +69 -0
- package/node_modules/zod/src/v4/core/tests/locales/uz.test.ts +22 -0
- package/node_modules/zod/src/v4/core/tests/polyfill-collision.test.ts +46 -0
- package/node_modules/zod/src/v4/core/tests/record-constructor.test.ts +58 -0
- package/node_modules/zod/src/v4/core/tests/treeshake.test.ts +51 -0
- package/node_modules/zod/src/v4/core/tests/url-no-canparse.test.ts +133 -0
- package/node_modules/zod/src/v4/core/to-json-schema.ts +288 -44
- package/node_modules/zod/src/v4/core/util.ts +506 -179
- package/node_modules/zod/src/v4/core/versions.ts +2 -2
- package/node_modules/zod/src/v4/core/visit.ts +193 -0
- package/node_modules/zod/src/v4/index.ts +3 -3
- package/node_modules/zod/src/v4/locales/ar.ts +5 -0
- package/node_modules/zod/src/v4/locales/az.ts +5 -0
- package/node_modules/zod/src/v4/locales/be.ts +12 -0
- package/node_modules/zod/src/v4/locales/bg.ts +5 -0
- package/node_modules/zod/src/v4/locales/bn.ts +123 -0
- package/node_modules/zod/src/v4/locales/ca.ts +5 -0
- package/node_modules/zod/src/v4/locales/ckb.ts +140 -0
- package/node_modules/zod/src/v4/locales/cs.ts +5 -0
- package/node_modules/zod/src/v4/locales/da.ts +7 -2
- package/node_modules/zod/src/v4/locales/de.ts +5 -0
- package/node_modules/zod/src/v4/locales/el.ts +124 -0
- package/node_modules/zod/src/v4/locales/en.ts +21 -4
- package/node_modules/zod/src/v4/locales/eo.ts +5 -0
- package/node_modules/zod/src/v4/locales/es.ts +4 -0
- package/node_modules/zod/src/v4/locales/fa.ts +5 -0
- package/node_modules/zod/src/v4/locales/fi.ts +5 -0
- package/node_modules/zod/src/v4/locales/fr-CA.ts +5 -0
- package/node_modules/zod/src/v4/locales/fr.ts +41 -18
- package/node_modules/zod/src/v4/locales/gu.ts +123 -0
- package/node_modules/zod/src/v4/locales/he.ts +8 -1
- package/node_modules/zod/src/v4/locales/hi.ts +126 -0
- package/node_modules/zod/src/v4/locales/hr.ts +135 -0
- package/node_modules/zod/src/v4/locales/hu.ts +5 -0
- package/node_modules/zod/src/v4/locales/hy.ts +11 -0
- package/node_modules/zod/src/v4/locales/id.ts +5 -0
- package/node_modules/zod/src/v4/locales/index.ts +14 -0
- package/node_modules/zod/src/v4/locales/is.ts +5 -0
- package/node_modules/zod/src/v4/locales/it.ts +6 -1
- package/node_modules/zod/src/v4/locales/ja.ts +5 -0
- package/node_modules/zod/src/v4/locales/ka.ts +13 -8
- package/node_modules/zod/src/v4/locales/km.ts +5 -0
- package/node_modules/zod/src/v4/locales/kn.ts +126 -0
- package/node_modules/zod/src/v4/locales/ko.ts +5 -0
- package/node_modules/zod/src/v4/locales/lt.ts +4 -0
- package/node_modules/zod/src/v4/locales/mk.ts +5 -0
- package/node_modules/zod/src/v4/locales/ms.ts +5 -0
- package/node_modules/zod/src/v4/locales/ne.ts +128 -0
- package/node_modules/zod/src/v4/locales/nl.ts +5 -0
- package/node_modules/zod/src/v4/locales/nn.ts +121 -0
- package/node_modules/zod/src/v4/locales/no.ts +7 -2
- package/node_modules/zod/src/v4/locales/ota.ts +5 -0
- package/node_modules/zod/src/v4/locales/pl.ts +5 -0
- package/node_modules/zod/src/v4/locales/ps.ts +5 -0
- package/node_modules/zod/src/v4/locales/pt-BR.ts +161 -0
- package/node_modules/zod/src/v4/locales/pt.ts +101 -58
- package/node_modules/zod/src/v4/locales/ro.ts +132 -0
- package/node_modules/zod/src/v4/locales/ru.ts +12 -0
- package/node_modules/zod/src/v4/locales/sk.ts +123 -0
- package/node_modules/zod/src/v4/locales/sl.ts +5 -0
- package/node_modules/zod/src/v4/locales/sv.ts +7 -2
- package/node_modules/zod/src/v4/locales/ta.ts +5 -0
- package/node_modules/zod/src/v4/locales/tg.ts +135 -0
- package/node_modules/zod/src/v4/locales/th.ts +5 -0
- package/node_modules/zod/src/v4/locales/tk.ts +113 -0
- package/node_modules/zod/src/v4/locales/tr.ts +5 -0
- package/node_modules/zod/src/v4/locales/uk.ts +5 -0
- package/node_modules/zod/src/v4/locales/ur.ts +5 -0
- package/node_modules/zod/src/v4/locales/uz.ts +4 -0
- package/node_modules/zod/src/v4/locales/vi.ts +5 -0
- package/node_modules/zod/src/v4/locales/yo.ts +5 -0
- package/node_modules/zod/src/v4/locales/zh-CN.ts +5 -0
- package/node_modules/zod/src/v4/locales/zh-TW.ts +5 -0
- package/node_modules/zod/src/v4/mini/checks.ts +1 -0
- package/node_modules/zod/src/v4/mini/deep-partial.ts +73 -0
- package/node_modules/zod/src/v4/mini/external.ts +13 -1
- package/node_modules/zod/src/v4/mini/in-out.ts +45 -0
- package/node_modules/zod/src/v4/mini/parse.ts +2 -0
- package/node_modules/zod/src/v4/mini/schemas.ts +214 -79
- package/node_modules/zod/src/v4/mini/tests/apply.test.ts +33 -0
- package/node_modules/zod/src/v4/mini/tests/assignability.test.ts +62 -1
- package/node_modules/zod/src/v4/mini/tests/checks.test.ts +14 -0
- package/node_modules/zod/src/v4/mini/tests/codec.test.ts +54 -1
- package/node_modules/zod/src/v4/mini/tests/computed.test.ts +11 -17
- package/node_modules/zod/src/v4/mini/tests/cyclic-data.test.ts +84 -0
- package/node_modules/zod/src/v4/mini/tests/deep-partial.test.ts +54 -0
- package/node_modules/zod/src/v4/mini/tests/error.test.ts +23 -4
- package/node_modules/zod/src/v4/mini/tests/functions.test.ts +9 -0
- package/node_modules/zod/src/v4/mini/tests/index.test.ts +187 -4
- package/node_modules/zod/src/v4/mini/tests/number.test.ts +14 -0
- package/node_modules/zod/src/v4/mini/tests/object.test.ts +74 -9
- package/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts +67 -1
- package/node_modules/zod/src/v4/mini/tests/string.test.ts +49 -0
- package/node_modules/zod/v3/ZodError.cjs +41 -12
- package/node_modules/zod/v3/ZodError.d.cts +1 -1
- package/node_modules/zod/v3/ZodError.d.ts +1 -1
- package/node_modules/zod/v3/ZodError.js +22 -12
- package/node_modules/zod/v3/errors.cjs +19 -0
- package/node_modules/zod/v3/external.cjs +19 -0
- package/node_modules/zod/v3/helpers/enumUtil.cjs +19 -0
- package/node_modules/zod/v3/helpers/errorUtil.cjs +20 -1
- package/node_modules/zod/v3/helpers/errorUtil.js +1 -1
- package/node_modules/zod/v3/helpers/parseUtil.cjs +19 -0
- package/node_modules/zod/v3/helpers/partialUtil.cjs +19 -0
- package/node_modules/zod/v3/helpers/typeAliases.cjs +19 -0
- package/node_modules/zod/v3/helpers/util.cjs +19 -0
- package/node_modules/zod/v3/index.cjs +19 -0
- package/node_modules/zod/v3/package.json +2 -1
- package/node_modules/zod/v3/standard-schema.cjs +19 -0
- package/node_modules/zod/v3/types.cjs +26 -5
- package/node_modules/zod/v3/types.js +7 -5
- package/node_modules/zod/v4/classic/checks.cjs +21 -1
- package/node_modules/zod/v4/classic/checks.d.cts +1 -1
- package/node_modules/zod/v4/classic/checks.d.ts +1 -1
- package/node_modules/zod/v4/classic/checks.js +1 -1
- package/node_modules/zod/v4/classic/coerce.cjs +19 -0
- package/node_modules/zod/v4/classic/compat.cjs +19 -0
- package/node_modules/zod/v4/classic/compat.d.cts +9 -11
- package/node_modules/zod/v4/classic/compat.d.ts +9 -11
- package/node_modules/zod/v4/classic/deep-partial.cjs +58 -0
- package/node_modules/zod/v4/classic/deep-partial.d.cts +14 -0
- package/node_modules/zod/v4/classic/deep-partial.d.ts +14 -0
- package/node_modules/zod/v4/classic/deep-partial.js +13 -0
- package/node_modules/zod/v4/classic/errors.cjs +62 -34
- package/node_modules/zod/v4/classic/errors.d.cts +3 -4
- package/node_modules/zod/v4/classic/errors.d.ts +3 -4
- package/node_modules/zod/v4/classic/errors.js +44 -35
- package/node_modules/zod/v4/classic/external.cjs +51 -27
- package/node_modules/zod/v4/classic/external.d.cts +6 -2
- package/node_modules/zod/v4/classic/external.d.ts +6 -2
- package/node_modules/zod/v4/classic/external.js +5 -8
- package/node_modules/zod/v4/classic/from-json-schema.cjs +394 -78
- package/node_modules/zod/v4/classic/from-json-schema.js +375 -78
- package/node_modules/zod/v4/classic/in-out.cjs +82 -0
- package/node_modules/zod/v4/classic/in-out.d.cts +8 -0
- package/node_modules/zod/v4/classic/in-out.d.ts +8 -0
- package/node_modules/zod/v4/classic/in-out.js +36 -0
- package/node_modules/zod/v4/classic/index.cjs +21 -2
- package/node_modules/zod/v4/classic/index.d.cts +1 -2
- package/node_modules/zod/v4/classic/index.d.ts +1 -2
- package/node_modules/zod/v4/classic/index.js +2 -2
- package/node_modules/zod/v4/classic/iso.cjs +30 -22
- package/node_modules/zod/v4/classic/iso.d.cts +2 -17
- package/node_modules/zod/v4/classic/iso.d.ts +2 -17
- package/node_modules/zod/v4/classic/iso.js +2 -17
- package/node_modules/zod/v4/classic/package.json +2 -1
- package/node_modules/zod/v4/classic/parse.cjs +23 -1
- package/node_modules/zod/v4/classic/parse.d.cts +17 -4
- package/node_modules/zod/v4/classic/parse.d.ts +17 -4
- package/node_modules/zod/v4/classic/parse.js +1 -0
- package/node_modules/zod/v4/classic/schemas.cjs +629 -225
- package/node_modules/zod/v4/classic/schemas.d.cts +104 -27
- package/node_modules/zod/v4/classic/schemas.d.ts +104 -27
- package/node_modules/zod/v4/classic/schemas.js +601 -223
- package/node_modules/zod/v4/core/api.cjs +73 -26
- package/node_modules/zod/v4/core/api.d.cts +40 -9
- package/node_modules/zod/v4/core/api.d.ts +40 -9
- package/node_modules/zod/v4/core/api.js +51 -26
- package/node_modules/zod/v4/core/checks.cjs +88 -128
- package/node_modules/zod/v4/core/checks.d.cts +30 -14
- package/node_modules/zod/v4/core/checks.d.ts +30 -14
- package/node_modules/zod/v4/core/checks.js +68 -127
- package/node_modules/zod/v4/core/compile.cjs +1916 -0
- package/node_modules/zod/v4/core/compile.d.cts +65 -0
- package/node_modules/zod/v4/core/compile.d.ts +65 -0
- package/node_modules/zod/v4/core/compile.js +1866 -0
- package/node_modules/zod/v4/core/core.cjs +104 -20
- package/node_modules/zod/v4/core/core.d.cts +16 -4
- package/node_modules/zod/v4/core/core.d.ts +16 -4
- package/node_modules/zod/v4/core/core.js +87 -22
- package/node_modules/zod/v4/core/doc.cjs +31 -9
- package/node_modules/zod/v4/core/doc.d.cts +3 -1
- package/node_modules/zod/v4/core/doc.d.ts +3 -1
- package/node_modules/zod/v4/core/doc.js +12 -9
- package/node_modules/zod/v4/core/errors.cjs +146 -42
- package/node_modules/zod/v4/core/errors.d.cts +5 -0
- package/node_modules/zod/v4/core/errors.d.ts +5 -0
- package/node_modules/zod/v4/core/errors.js +127 -42
- package/node_modules/zod/v4/core/index.cjs +24 -1
- package/node_modules/zod/v4/core/index.d.cts +3 -0
- package/node_modules/zod/v4/core/index.d.ts +3 -0
- package/node_modules/zod/v4/core/index.js +3 -0
- package/node_modules/zod/v4/core/json-schema-generator.cjs +24 -1
- package/node_modules/zod/v4/core/json-schema-generator.d.cts +2 -2
- package/node_modules/zod/v4/core/json-schema-generator.d.ts +2 -2
- package/node_modules/zod/v4/core/json-schema-generator.js +6 -2
- package/node_modules/zod/v4/core/json-schema-processors.cjs +454 -173
- package/node_modules/zod/v4/core/json-schema-processors.d.cts +16 -0
- package/node_modules/zod/v4/core/json-schema-processors.d.ts +16 -0
- package/node_modules/zod/v4/core/json-schema-processors.js +413 -175
- package/node_modules/zod/v4/core/json-schema.cjs +19 -0
- package/node_modules/zod/v4/core/json-schema.d.cts +2 -1
- package/node_modules/zod/v4/core/json-schema.d.ts +2 -1
- package/node_modules/zod/v4/core/memoizer.cjs +360 -0
- package/node_modules/zod/v4/core/memoizer.d.cts +15 -0
- package/node_modules/zod/v4/core/memoizer.d.ts +15 -0
- package/node_modules/zod/v4/core/memoizer.js +311 -0
- package/node_modules/zod/v4/core/package.json +2 -1
- package/node_modules/zod/v4/core/parse.cjs +151 -49
- package/node_modules/zod/v4/core/parse.d.cts +14 -11
- package/node_modules/zod/v4/core/parse.d.ts +14 -11
- package/node_modules/zod/v4/core/parse.js +130 -48
- package/node_modules/zod/v4/core/regexes.cjs +61 -18
- package/node_modules/zod/v4/core/regexes.d.cts +11 -0
- package/node_modules/zod/v4/core/regexes.d.ts +11 -0
- package/node_modules/zod/v4/core/regexes.js +39 -16
- package/node_modules/zod/v4/core/registries.cjs +19 -0
- package/node_modules/zod/v4/core/registries.js +2 -2
- package/node_modules/zod/v4/core/schemas.cjs +957 -382
- package/node_modules/zod/v4/core/schemas.d.cts +154 -25
- package/node_modules/zod/v4/core/schemas.d.ts +154 -25
- package/node_modules/zod/v4/core/schemas.js +925 -382
- package/node_modules/zod/v4/core/standard-schema.cjs +19 -0
- package/node_modules/zod/v4/core/to-json-schema.cjs +275 -40
- package/node_modules/zod/v4/core/to-json-schema.d.cts +45 -5
- package/node_modules/zod/v4/core/to-json-schema.d.ts +45 -5
- package/node_modules/zod/v4/core/to-json-schema.js +253 -39
- package/node_modules/zod/v4/core/util.cjs +428 -174
- package/node_modules/zod/v4/core/util.d.cts +82 -1
- package/node_modules/zod/v4/core/util.d.ts +82 -1
- package/node_modules/zod/v4/core/util.js +397 -175
- package/node_modules/zod/v4/core/versions.cjs +21 -2
- package/node_modules/zod/v4/core/versions.d.cts +1 -1
- package/node_modules/zod/v4/core/versions.d.ts +1 -1
- package/node_modules/zod/v4/core/versions.js +2 -2
- package/node_modules/zod/v4/core/visit.cjs +214 -0
- package/node_modules/zod/v4/core/visit.d.cts +30 -0
- package/node_modules/zod/v4/core/visit.d.ts +30 -0
- package/node_modules/zod/v4/core/visit.js +169 -0
- package/node_modules/zod/v4/index.cjs +34 -5
- package/node_modules/zod/v4/index.d.cts +2 -2
- package/node_modules/zod/v4/index.d.ts +2 -2
- package/node_modules/zod/v4/index.js +3 -2
- package/node_modules/zod/v4/locales/ar.cjs +5 -0
- package/node_modules/zod/v4/locales/ar.js +5 -0
- package/node_modules/zod/v4/locales/az.cjs +5 -0
- package/node_modules/zod/v4/locales/az.js +5 -0
- package/node_modules/zod/v4/locales/be.cjs +12 -0
- package/node_modules/zod/v4/locales/be.js +12 -0
- package/node_modules/zod/v4/locales/bg.cjs +5 -0
- package/node_modules/zod/v4/locales/bg.js +5 -0
- package/node_modules/zod/v4/locales/bn.cjs +140 -0
- package/node_modules/zod/v4/locales/bn.d.cts +5 -0
- package/node_modules/zod/v4/locales/bn.d.ts +4 -0
- package/node_modules/zod/v4/locales/bn.js +113 -0
- package/node_modules/zod/v4/locales/ca.cjs +5 -0
- package/node_modules/zod/v4/locales/ca.js +5 -0
- package/node_modules/zod/v4/locales/ckb.cjs +160 -0
- package/node_modules/zod/v4/locales/ckb.d.cts +5 -0
- package/node_modules/zod/v4/locales/ckb.d.ts +4 -0
- package/node_modules/zod/v4/locales/ckb.js +133 -0
- package/node_modules/zod/v4/locales/cs.cjs +5 -0
- package/node_modules/zod/v4/locales/cs.js +5 -0
- package/node_modules/zod/v4/locales/da.cjs +7 -2
- package/node_modules/zod/v4/locales/da.js +7 -2
- package/node_modules/zod/v4/locales/de.cjs +5 -0
- package/node_modules/zod/v4/locales/de.js +5 -0
- package/node_modules/zod/v4/locales/el.cjs +139 -0
- package/node_modules/zod/v4/locales/el.d.cts +5 -0
- package/node_modules/zod/v4/locales/el.d.ts +4 -0
- package/node_modules/zod/v4/locales/el.js +112 -0
- package/node_modules/zod/v4/locales/en.cjs +20 -4
- package/node_modules/zod/v4/locales/en.js +20 -4
- package/node_modules/zod/v4/locales/eo.cjs +5 -0
- package/node_modules/zod/v4/locales/eo.js +5 -0
- package/node_modules/zod/v4/locales/es.cjs +4 -0
- package/node_modules/zod/v4/locales/es.js +4 -0
- package/node_modules/zod/v4/locales/fa.cjs +5 -0
- package/node_modules/zod/v4/locales/fa.js +5 -0
- package/node_modules/zod/v4/locales/fi.cjs +5 -0
- package/node_modules/zod/v4/locales/fi.js +5 -0
- package/node_modules/zod/v4/locales/fr-CA.cjs +5 -0
- package/node_modules/zod/v4/locales/fr-CA.js +5 -0
- package/node_modules/zod/v4/locales/fr.cjs +38 -17
- package/node_modules/zod/v4/locales/fr.js +38 -17
- package/node_modules/zod/v4/locales/gu.cjs +140 -0
- package/node_modules/zod/v4/locales/gu.d.cts +5 -0
- package/node_modules/zod/v4/locales/gu.d.ts +4 -0
- package/node_modules/zod/v4/locales/gu.js +113 -0
- package/node_modules/zod/v4/locales/he.cjs +7 -0
- package/node_modules/zod/v4/locales/he.js +7 -0
- package/node_modules/zod/v4/locales/hi.cjs +138 -0
- package/node_modules/zod/v4/locales/hi.d.cts +5 -0
- package/node_modules/zod/v4/locales/hi.d.ts +4 -0
- package/node_modules/zod/v4/locales/hi.js +111 -0
- package/node_modules/zod/v4/locales/hr.cjs +153 -0
- package/node_modules/zod/v4/locales/hr.d.cts +5 -0
- package/node_modules/zod/v4/locales/hr.d.ts +4 -0
- package/node_modules/zod/v4/locales/hr.js +126 -0
- package/node_modules/zod/v4/locales/hu.cjs +5 -0
- package/node_modules/zod/v4/locales/hu.js +5 -0
- package/node_modules/zod/v4/locales/hy.cjs +11 -0
- package/node_modules/zod/v4/locales/hy.js +11 -0
- package/node_modules/zod/v4/locales/id.cjs +5 -0
- package/node_modules/zod/v4/locales/id.js +5 -0
- package/node_modules/zod/v4/locales/index.cjs +49 -1
- package/node_modules/zod/v4/locales/index.d.cts +14 -0
- package/node_modules/zod/v4/locales/index.d.ts +14 -0
- package/node_modules/zod/v4/locales/index.js +14 -0
- package/node_modules/zod/v4/locales/is.cjs +5 -0
- package/node_modules/zod/v4/locales/is.js +5 -0
- package/node_modules/zod/v4/locales/it.cjs +6 -1
- package/node_modules/zod/v4/locales/it.js +6 -1
- package/node_modules/zod/v4/locales/ja.cjs +5 -0
- package/node_modules/zod/v4/locales/ja.js +5 -0
- package/node_modules/zod/v4/locales/ka.cjs +13 -8
- package/node_modules/zod/v4/locales/ka.js +13 -8
- package/node_modules/zod/v4/locales/km.cjs +5 -0
- package/node_modules/zod/v4/locales/km.js +5 -0
- package/node_modules/zod/v4/locales/kn.cjs +143 -0
- package/node_modules/zod/v4/locales/kn.d.cts +5 -0
- package/node_modules/zod/v4/locales/kn.d.ts +4 -0
- package/node_modules/zod/v4/locales/kn.js +116 -0
- package/node_modules/zod/v4/locales/ko.cjs +5 -0
- package/node_modules/zod/v4/locales/ko.js +5 -0
- package/node_modules/zod/v4/locales/lt.cjs +4 -0
- package/node_modules/zod/v4/locales/lt.js +4 -0
- package/node_modules/zod/v4/locales/mk.cjs +5 -0
- package/node_modules/zod/v4/locales/mk.js +5 -0
- package/node_modules/zod/v4/locales/ms.cjs +5 -0
- package/node_modules/zod/v4/locales/ms.js +5 -0
- package/node_modules/zod/v4/locales/ne.cjs +138 -0
- package/node_modules/zod/v4/locales/ne.d.cts +5 -0
- package/node_modules/zod/v4/locales/ne.d.ts +4 -0
- package/node_modules/zod/v4/locales/ne.js +111 -0
- package/node_modules/zod/v4/locales/nl.cjs +5 -0
- package/node_modules/zod/v4/locales/nl.js +5 -0
- package/node_modules/zod/v4/locales/nn.cjs +140 -0
- package/node_modules/zod/v4/locales/nn.d.cts +5 -0
- package/node_modules/zod/v4/locales/nn.d.ts +4 -0
- package/node_modules/zod/v4/locales/nn.js +113 -0
- package/node_modules/zod/v4/locales/no.cjs +7 -2
- package/node_modules/zod/v4/locales/no.js +7 -2
- package/node_modules/zod/v4/locales/ota.cjs +5 -0
- package/node_modules/zod/v4/locales/ota.js +5 -0
- package/node_modules/zod/v4/locales/package.json +2 -1
- package/node_modules/zod/v4/locales/pl.cjs +5 -0
- package/node_modules/zod/v4/locales/pl.js +5 -0
- package/node_modules/zod/v4/locales/ps.cjs +5 -0
- package/node_modules/zod/v4/locales/ps.js +5 -0
- package/node_modules/zod/v4/locales/pt-BR.cjs +170 -0
- package/node_modules/zod/v4/locales/pt-BR.d.cts +5 -0
- package/node_modules/zod/v4/locales/pt-BR.d.ts +4 -0
- package/node_modules/zod/v4/locales/pt-BR.js +143 -0
- package/node_modules/zod/v4/locales/pt.cjs +89 -55
- package/node_modules/zod/v4/locales/pt.js +89 -55
- package/node_modules/zod/v4/locales/ro.cjs +149 -0
- package/node_modules/zod/v4/locales/ro.d.cts +5 -0
- package/node_modules/zod/v4/locales/ro.d.ts +4 -0
- package/node_modules/zod/v4/locales/ro.js +122 -0
- package/node_modules/zod/v4/locales/ru.cjs +12 -0
- package/node_modules/zod/v4/locales/ru.js +12 -0
- package/node_modules/zod/v4/locales/sk.cjs +143 -0
- package/node_modules/zod/v4/locales/sk.d.cts +5 -0
- package/node_modules/zod/v4/locales/sk.d.ts +4 -0
- package/node_modules/zod/v4/locales/sk.js +116 -0
- package/node_modules/zod/v4/locales/sl.cjs +5 -0
- package/node_modules/zod/v4/locales/sl.js +5 -0
- package/node_modules/zod/v4/locales/sv.cjs +7 -2
- package/node_modules/zod/v4/locales/sv.js +7 -2
- package/node_modules/zod/v4/locales/ta.cjs +5 -0
- package/node_modules/zod/v4/locales/ta.js +5 -0
- package/node_modules/zod/v4/locales/tg.cjs +144 -0
- package/node_modules/zod/v4/locales/tg.d.cts +5 -0
- package/node_modules/zod/v4/locales/tg.d.ts +4 -0
- package/node_modules/zod/v4/locales/tg.js +117 -0
- package/node_modules/zod/v4/locales/th.cjs +5 -0
- package/node_modules/zod/v4/locales/th.js +5 -0
- package/node_modules/zod/v4/locales/tk.cjs +134 -0
- package/node_modules/zod/v4/locales/tk.d.cts +5 -0
- package/node_modules/zod/v4/locales/tk.d.ts +4 -0
- package/node_modules/zod/v4/locales/tk.js +107 -0
- package/node_modules/zod/v4/locales/tr.cjs +5 -0
- package/node_modules/zod/v4/locales/tr.js +5 -0
- package/node_modules/zod/v4/locales/uk.cjs +5 -0
- package/node_modules/zod/v4/locales/uk.js +5 -0
- package/node_modules/zod/v4/locales/ur.cjs +5 -0
- package/node_modules/zod/v4/locales/ur.js +5 -0
- package/node_modules/zod/v4/locales/uz.cjs +4 -0
- package/node_modules/zod/v4/locales/uz.js +4 -0
- package/node_modules/zod/v4/locales/vi.cjs +5 -0
- package/node_modules/zod/v4/locales/vi.js +5 -0
- package/node_modules/zod/v4/locales/yo.cjs +5 -0
- package/node_modules/zod/v4/locales/yo.js +5 -0
- package/node_modules/zod/v4/locales/zh-CN.cjs +5 -0
- package/node_modules/zod/v4/locales/zh-CN.js +5 -0
- package/node_modules/zod/v4/locales/zh-TW.cjs +5 -0
- package/node_modules/zod/v4/locales/zh-TW.js +5 -0
- package/node_modules/zod/v4/mini/checks.cjs +21 -1
- package/node_modules/zod/v4/mini/checks.d.cts +1 -1
- package/node_modules/zod/v4/mini/checks.d.ts +1 -1
- package/node_modules/zod/v4/mini/checks.js +1 -1
- package/node_modules/zod/v4/mini/coerce.cjs +19 -0
- package/node_modules/zod/v4/mini/deep-partial.cjs +58 -0
- package/node_modules/zod/v4/mini/deep-partial.d.cts +14 -0
- package/node_modules/zod/v4/mini/deep-partial.d.ts +14 -0
- package/node_modules/zod/v4/mini/deep-partial.js +13 -0
- package/node_modules/zod/v4/mini/external.cjs +33 -1
- package/node_modules/zod/v4/mini/external.d.cts +6 -2
- package/node_modules/zod/v4/mini/external.d.ts +6 -2
- package/node_modules/zod/v4/mini/external.js +3 -1
- package/node_modules/zod/v4/mini/in-out.cjs +82 -0
- package/node_modules/zod/v4/mini/in-out.d.cts +8 -0
- package/node_modules/zod/v4/mini/in-out.d.ts +8 -0
- package/node_modules/zod/v4/mini/in-out.js +36 -0
- package/node_modules/zod/v4/mini/index.cjs +19 -0
- package/node_modules/zod/v4/mini/iso.cjs +19 -0
- package/node_modules/zod/v4/mini/package.json +2 -1
- package/node_modules/zod/v4/mini/parse.cjs +22 -1
- package/node_modules/zod/v4/mini/parse.d.cts +1 -1
- package/node_modules/zod/v4/mini/parse.d.ts +1 -1
- package/node_modules/zod/v4/mini/parse.js +1 -1
- package/node_modules/zod/v4/mini/schemas.cjs +151 -50
- package/node_modules/zod/v4/mini/schemas.d.cts +75 -22
- package/node_modules/zod/v4/mini/schemas.d.ts +75 -22
- package/node_modules/zod/v4/mini/schemas.js +125 -48
- package/node_modules/zod/v4/package.json +2 -1
- package/node_modules/zod/v4-mini/index.cjs +19 -0
- package/node_modules/zod/v4-mini/package.json +2 -1
- package/package.json +16 -14
- package/dist/trpc/routers/searchees.d.ts +0 -51
- package/dist/trpc/routers/searchees.js +0 -156
- package/dist/trpc/routers/searchees.js.map +0 -1
- package/dist/webui/assets/ClientOnly-CzZIsGML.js +0 -1
- package/dist/webui/assets/DeleteOption-dxKSbv6N.js +0 -1
- package/dist/webui/assets/FieldInfo-FLjtPgL4.js +0 -1
- package/dist/webui/assets/Page-C7KClZ28.js +0 -1
- package/dist/webui/assets/array-field-DGB7Lbh7.js +0 -1
- package/dist/webui/assets/badge-hukNSIir.js +0 -1
- package/dist/webui/assets/button-1cIaa9Lf.js +0 -1
- package/dist/webui/assets/check-CUrWQ2C7.js +0 -1
- package/dist/webui/assets/chevron-down-CVVogpPh.js +0 -1
- package/dist/webui/assets/clients-CHdgqO4r.js +0 -1
- package/dist/webui/assets/connect-Cr6Q3W8U.js +0 -2
- package/dist/webui/assets/createLucideIcon-zYRS_Hrv.js +0 -1
- package/dist/webui/assets/debug-CEmoQ2W_.js +0 -1
- package/dist/webui/assets/directories-CNuHKfHz.js +0 -1
- package/dist/webui/assets/dist-Bbmh5Du9.js +0 -1
- package/dist/webui/assets/dist-DhH_lYkz.js +0 -1
- package/dist/webui/assets/dist-DzdkRn7I.js +0 -1
- package/dist/webui/assets/dist-b2njvUJz.js +0 -41
- package/dist/webui/assets/dist-d-Lt00zD.js +0 -1
- package/dist/webui/assets/duration-field-CnlQcr37.js +0 -1
- package/dist/webui/assets/form-context-B-ekdUc0.js +0 -1
- package/dist/webui/assets/form-validation-context-CPAPOloL.js +0 -1
- package/dist/webui/assets/general-Cs8dEydJ.js +0 -1
- package/dist/webui/assets/health-DugF7R6A.js +0 -1
- package/dist/webui/assets/index-DhV1H9AB.css +0 -2
- package/dist/webui/assets/index-DinSQfHc.js +0 -11
- package/dist/webui/assets/input-CsfmMUT5.js +0 -1
- package/dist/webui/assets/jobs-Cr1xWWzM.js +0 -1
- package/dist/webui/assets/library-BNsctrbc.js +0 -1
- package/dist/webui/assets/loader-circle-BQbzoYGJ.js +0 -1
- package/dist/webui/assets/logs-C1l3cu_j.js +0 -1
- package/dist/webui/assets/number-field-Ce3QdLSz.js +0 -1
- package/dist/webui/assets/react-dom-mEftaaxx.js +0 -1
- package/dist/webui/assets/required-indicator-BXf2UzTH.js +0 -1
- package/dist/webui/assets/routes-Bw2nXmFg.js +0 -1
- package/dist/webui/assets/search-D9W5vk_0.js +0 -1
- package/dist/webui/assets/select-CZn10WME.js +0 -1
- package/dist/webui/assets/select-field-DozTirAZ.js +0 -1
- package/dist/webui/assets/settings-BXbhXNDK.js +0 -1
- package/dist/webui/assets/sidebar-y9WJu7Jw.js +0 -5
- package/dist/webui/assets/submit-button-CBOzR0f_.js +0 -1
- package/dist/webui/assets/switch-D4S9As9u.js +0 -1
- package/dist/webui/assets/switch-field-2E9ctvy_.js +0 -1
- package/dist/webui/assets/table-B1Y18B60.js +0 -1
- package/dist/webui/assets/text-field-DV4EP-I8.js +0 -1
- package/dist/webui/assets/time-DjUFOA4D.js +0 -1
- package/dist/webui/assets/trackers-ULhLxA6-.js +0 -7
- package/dist/webui/assets/use-settings-form-submit-D87nmJRy.js +0 -79
- package/dist/webui/assets/useBaseQuery-BvrWhgOK.js +0 -1
- package/dist/webui/assets/useRouterState-CZfD5Xdv.js +0 -1
- package/dist/webui/assets/useStore-CusP06SD.js +0 -1
- package/node_modules/zod/src/v4/core/config.ts +0 -15
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type { $ZodTypeDiscriminable } from "./api.js";
|
|
2
1
|
import * as checks from "./checks.js";
|
|
2
|
+
import type { $ZodNumberFormats } from "./checks.js";
|
|
3
|
+
import type { $ZodBigIntFormats } from "./checks.js";
|
|
3
4
|
import * as core from "./core.js";
|
|
4
5
|
import { Doc } from "./doc.js";
|
|
5
6
|
import type * as errors from "./errors.js";
|
|
6
7
|
import type * as JSONSchema from "./json-schema.js";
|
|
7
|
-
import { parse, parseAsync
|
|
8
|
+
import { parse, parseAsync } from "./parse.js";
|
|
8
9
|
import * as regexes from "./regexes.js";
|
|
9
10
|
import type { StandardSchemaV1 } from "./standard-schema.js";
|
|
10
11
|
import type { ProcessParams, ToJSONSchemaContext } from "./to-json-schema.js";
|
|
@@ -29,13 +30,25 @@ export interface ParseContextInternal<T extends errors.$ZodIssueBase = never> ex
|
|
|
29
30
|
readonly async?: boolean | undefined;
|
|
30
31
|
readonly direction?: "forward" | "backward";
|
|
31
32
|
readonly skipChecks?: boolean;
|
|
33
|
+
/** Set only by `validate`/`validateAsync`. A container may stop before its next child, never inside one, so a map entry and a tuple's fixed items parse whole. */
|
|
34
|
+
readonly abortEarly?: boolean;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Gives a container cycle support: `attach` wraps its parse, and `alloc` registers the object it builds into before any child is parsed so a reference back to the same input resolves to it. */
|
|
38
|
+
export interface $ZodMemoizer {
|
|
39
|
+
attach(inst: $ZodType): void;
|
|
40
|
+
guard(inst: $ZodType): void;
|
|
41
|
+
alloc<T extends object>(inst: $ZodType, payload: ParsePayload, empty: T, ctx: ParseContextInternal): T;
|
|
32
42
|
}
|
|
33
43
|
|
|
34
44
|
export interface ParsePayload<T = unknown> {
|
|
35
45
|
value: T;
|
|
36
46
|
issues: errors.$ZodRawIssue[];
|
|
37
|
-
/** A
|
|
47
|
+
/** A way to mark a whole payload as aborted. Used in codecs/pipes. */
|
|
38
48
|
aborted?: boolean;
|
|
49
|
+
/** @internal Set when the value came from a repeat visit to a node still being
|
|
50
|
+
* parsed. Its checks run on the node itself, against the finished value. */
|
|
51
|
+
memo?: boolean | undefined;
|
|
39
52
|
}
|
|
40
53
|
|
|
41
54
|
export type CheckFn<T> = (input: ParsePayload<T>) => util.MaybeAsync<void>;
|
|
@@ -115,8 +128,13 @@ export interface _$ZodTypeInternals {
|
|
|
115
128
|
* @default Required
|
|
116
129
|
*/
|
|
117
130
|
|
|
118
|
-
/** @internal
|
|
119
|
-
|
|
131
|
+
/** @internal Three rungs, each strictly stronger than the last:
|
|
132
|
+
* undefined — required; the container may not omit this slot
|
|
133
|
+
* "optional" — the container may omit it; nothing is supplied in its place
|
|
134
|
+
* "defaulted" — the container may omit it AND this schema substitutes a value
|
|
135
|
+
* Consumers asking "may the slot be absent?" test `!== undefined`.
|
|
136
|
+
* $ZodOptional asks the stronger question and tests `=== "defaulted"`. */
|
|
137
|
+
optin?: "optional" | "defaulted" | undefined;
|
|
120
138
|
/** @internal */
|
|
121
139
|
optout?: "optional" | undefined;
|
|
122
140
|
|
|
@@ -182,136 +200,164 @@ export interface $ZodType<
|
|
|
182
200
|
export interface _$ZodType<T extends $ZodTypeInternals = $ZodTypeInternals>
|
|
183
201
|
extends $ZodType<T["output"], T["input"], T> {}
|
|
184
202
|
|
|
185
|
-
export const $ZodType: core.$constructor<$ZodType> = /*@__PURE__*/ core.$constructor
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
checks.
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
203
|
+
export const $ZodType: core.$constructor<$ZodType> = /*@__PURE__*/ core.$constructor<$ZodType>(
|
|
204
|
+
"$ZodType",
|
|
205
|
+
(inst, def) => {
|
|
206
|
+
inst ??= {} as any;
|
|
207
|
+
|
|
208
|
+
inst._zod.def = def; // set _def property
|
|
209
|
+
inst._zod.bag = inst._zod.bag || {}; // initialize _bag object
|
|
210
|
+
inst._zod.version = version;
|
|
211
|
+
|
|
212
|
+
const defChecks = inst._zod.def.checks;
|
|
213
|
+
// if inst is itself a checks.$ZodCheck, run it as a check
|
|
214
|
+
const checks: checks.$ZodCheck<never>[] = inst._zod.traits.has("$ZodCheck")
|
|
215
|
+
? [inst as any, ...(defChecks ?? [])]
|
|
216
|
+
: defChecks?.length
|
|
217
|
+
? [...defChecks]
|
|
218
|
+
: [];
|
|
219
|
+
|
|
220
|
+
for (const ch of checks) {
|
|
221
|
+
for (const fn of ch._zod.onattach) {
|
|
222
|
+
fn(inst);
|
|
223
|
+
}
|
|
202
224
|
}
|
|
203
|
-
}
|
|
204
225
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
226
|
+
if (checks.length === 0) {
|
|
227
|
+
// deferred initializer inst._zod.parse is not yet defined
|
|
228
|
+
inst._zod.deferred ??= [];
|
|
229
|
+
inst._zod.deferred?.push(() => {
|
|
230
|
+
inst._zod.run = inst._zod.parse;
|
|
231
|
+
});
|
|
232
|
+
} else {
|
|
233
|
+
const runChecks = (
|
|
234
|
+
payload: ParsePayload,
|
|
235
|
+
checks: checks.$ZodCheck<never>[],
|
|
236
|
+
ctx?: ParseContextInternal | undefined
|
|
237
|
+
): util.MaybeAsync<ParsePayload> => {
|
|
238
|
+
if (payload.memo) return payload;
|
|
239
|
+
|
|
240
|
+
let isAborted = util.aborted(payload);
|
|
241
|
+
|
|
242
|
+
let asyncResult!: Promise<unknown> | undefined;
|
|
243
|
+
for (const ch of checks) {
|
|
244
|
+
if (ch._zod.def.when) {
|
|
245
|
+
if (util.explicitlyAborted(payload)) continue;
|
|
246
|
+
const shouldRun = ch._zod.def.when(payload);
|
|
247
|
+
if (!shouldRun) continue;
|
|
248
|
+
} else if (isAborted) {
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
const currLen = payload.issues.length;
|
|
252
|
+
const _ = ch._zod.check(payload as any) as any as ParsePayload;
|
|
230
253
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
254
|
+
if (_ instanceof Promise && ctx?.async === false) {
|
|
255
|
+
throw new core.$ZodAsyncError();
|
|
256
|
+
}
|
|
257
|
+
if (asyncResult || _ instanceof Promise) {
|
|
258
|
+
asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
|
|
259
|
+
await _;
|
|
260
|
+
const nextLen = payload.issues.length;
|
|
261
|
+
if (nextLen === currLen) return;
|
|
262
|
+
util.attachSchema(payload.issues, currLen, inst);
|
|
263
|
+
if (!isAborted) isAborted = util.aborted(payload, currLen);
|
|
264
|
+
});
|
|
265
|
+
} else {
|
|
237
266
|
const nextLen = payload.issues.length;
|
|
238
|
-
if (nextLen === currLen)
|
|
267
|
+
if (nextLen === currLen) continue;
|
|
268
|
+
util.attachSchema(payload.issues, currLen, inst);
|
|
239
269
|
if (!isAborted) isAborted = util.aborted(payload, currLen);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
if (asyncResult) {
|
|
274
|
+
return asyncResult.then(() => {
|
|
275
|
+
return payload;
|
|
240
276
|
});
|
|
241
|
-
} else {
|
|
242
|
-
const nextLen = payload.issues.length;
|
|
243
|
-
if (nextLen === currLen) continue;
|
|
244
|
-
if (!isAborted) isAborted = util.aborted(payload, currLen);
|
|
245
277
|
}
|
|
246
|
-
|
|
278
|
+
return payload;
|
|
279
|
+
};
|
|
247
280
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
};
|
|
281
|
+
const handleCanaryResult = (canary: ParsePayload, payload: ParsePayload, ctx: ParseContextInternal) => {
|
|
282
|
+
// abort if the canary is aborted
|
|
283
|
+
if (util.aborted(canary)) {
|
|
284
|
+
canary.aborted = true;
|
|
285
|
+
return canary;
|
|
286
|
+
}
|
|
255
287
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
288
|
+
// run checks first, then
|
|
289
|
+
const checkResult = runChecks(payload, checks, ctx);
|
|
290
|
+
if (checkResult instanceof Promise) {
|
|
291
|
+
if (ctx.async === false) throw new core.$ZodAsyncError();
|
|
292
|
+
return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));
|
|
293
|
+
}
|
|
294
|
+
return inst._zod.parse(checkResult, ctx);
|
|
295
|
+
};
|
|
262
296
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
};
|
|
297
|
+
inst._zod.run = (payload, ctx) => {
|
|
298
|
+
if (ctx.skipChecks) {
|
|
299
|
+
return inst._zod.parse(payload, ctx);
|
|
300
|
+
}
|
|
301
|
+
if (ctx.direction === "backward") {
|
|
302
|
+
// run canary initial pass (no checks)
|
|
303
|
+
const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true });
|
|
271
304
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
// run canary
|
|
278
|
-
// initial pass (no checks)
|
|
279
|
-
const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true });
|
|
305
|
+
if (canary instanceof Promise) {
|
|
306
|
+
return canary.then((canary) => {
|
|
307
|
+
return handleCanaryResult(canary, payload, ctx);
|
|
308
|
+
});
|
|
309
|
+
}
|
|
280
310
|
|
|
281
|
-
|
|
282
|
-
return canary.then((canary) => {
|
|
283
|
-
return handleCanaryResult(canary, payload, ctx);
|
|
284
|
-
});
|
|
311
|
+
return handleCanaryResult(canary, payload, ctx);
|
|
285
312
|
}
|
|
286
313
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
if (ctx.async === false) throw new core.$ZodAsyncError();
|
|
294
|
-
return result.then((result) => runChecks(result, checks, ctx));
|
|
295
|
-
}
|
|
314
|
+
// forward
|
|
315
|
+
const result = inst._zod.parse(payload, ctx);
|
|
316
|
+
if (result instanceof Promise) {
|
|
317
|
+
if (ctx.async === false) throw new core.$ZodAsyncError();
|
|
318
|
+
return result.then((result) => runChecks(result, checks, ctx));
|
|
319
|
+
}
|
|
296
320
|
|
|
297
|
-
|
|
298
|
-
|
|
321
|
+
return runChecks(result, checks, ctx);
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
// Wrappers extend this by installing a richer factory over it; reading it eagerly would defeat the laziness.
|
|
327
|
+
get "~standard"(): StandardSchemaV1.Props<any, any> {
|
|
328
|
+
return util.hide(this, "~standard", standardProps(this));
|
|
329
|
+
},
|
|
330
|
+
set "~standard"(value: StandardSchemaV1.Props<any, any>) {
|
|
331
|
+
util.own(this, "~standard", value);
|
|
332
|
+
},
|
|
299
333
|
}
|
|
334
|
+
);
|
|
335
|
+
|
|
336
|
+
/** The Standard Schema surface for `inst`. Shared so wrappers can extend it without forcing it. */
|
|
337
|
+
// a Standard Schema result only reports issues, so a failure finalizes them straight off the raw payload: no ZodError, and no lazy result to read through
|
|
338
|
+
const toStandardResult = (r: ParsePayload, ctx: ParseContextInternal) =>
|
|
339
|
+
r.issues.length ? { issues: r.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())) } : { value: r.value };
|
|
300
340
|
|
|
301
|
-
|
|
302
|
-
|
|
341
|
+
async function validateAsync(inst: $ZodType, value: unknown) {
|
|
342
|
+
const ctx: ParseContextInternal = { async: true };
|
|
343
|
+
return toStandardResult((await inst._zod.run({ value, issues: [] }, ctx)) as ParsePayload, ctx);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
export function standardProps(inst: $ZodType): StandardSchemaV1.Props<any, any> {
|
|
347
|
+
return {
|
|
303
348
|
validate: (value: unknown) => {
|
|
349
|
+
const ctx: ParseContextInternal = { async: false };
|
|
304
350
|
try {
|
|
305
|
-
const r =
|
|
306
|
-
|
|
307
|
-
} catch (_) {
|
|
308
|
-
|
|
309
|
-
|
|
351
|
+
const r = inst._zod.run({ value, issues: [] }, ctx);
|
|
352
|
+
if (!(r instanceof Promise)) return toStandardResult(r, ctx);
|
|
353
|
+
} catch (_) {}
|
|
354
|
+
// async function so a synchronously throwing check rejects instead of escaping validate
|
|
355
|
+
return validateAsync(inst, value);
|
|
310
356
|
},
|
|
311
357
|
vendor: "zod",
|
|
312
358
|
version: 1 as const,
|
|
313
|
-
}
|
|
314
|
-
}
|
|
359
|
+
};
|
|
360
|
+
}
|
|
315
361
|
|
|
316
362
|
export { clone } from "./util.js";
|
|
317
363
|
|
|
@@ -341,6 +387,8 @@ export interface $ZodStringInternals<Input> extends $ZodTypeInternals<string, In
|
|
|
341
387
|
patterns: Set<RegExp>;
|
|
342
388
|
format: string;
|
|
343
389
|
contentEncoding: string;
|
|
390
|
+
/** the pattern admits strings its `format` keyword forbids, so `toJSONSchema` must not emit it */
|
|
391
|
+
laxFormat: boolean;
|
|
344
392
|
}>;
|
|
345
393
|
}
|
|
346
394
|
|
|
@@ -350,7 +398,8 @@ export interface $ZodString<Input = unknown> extends _$ZodType<$ZodStringInterna
|
|
|
350
398
|
|
|
351
399
|
export const $ZodString: core.$constructor<$ZodString> = /*@__PURE__*/ core.$constructor("$ZodString", (inst, def) => {
|
|
352
400
|
$ZodType.init(inst, def);
|
|
353
|
-
|
|
401
|
+
// a format's own pattern, else unbounded; a template literal derives the check-aware form itself
|
|
402
|
+
inst._zod.pattern = (def as $ZodStringFormatDef).pattern ?? regexes.anyString;
|
|
354
403
|
inst._zod.parse = (payload, _) => {
|
|
355
404
|
if (def.coerce)
|
|
356
405
|
try {
|
|
@@ -471,54 +520,133 @@ export interface $ZodURL extends $ZodType {
|
|
|
471
520
|
_zod: $ZodURLInternals;
|
|
472
521
|
}
|
|
473
522
|
|
|
523
|
+
/** The `://` guard rejected the input before the URL constructor saw it. */
|
|
524
|
+
export const URL_BAD_FORMAT = 1;
|
|
525
|
+
/** The URL parser rejected the input. */
|
|
526
|
+
export const URL_UNPARSEABLE = 2;
|
|
527
|
+
|
|
528
|
+
export function canParseURL(input: string): boolean {
|
|
529
|
+
try {
|
|
530
|
+
if (typeof URL !== "undefined" && typeof URL.canParse === "function") return URL.canParse(input);
|
|
531
|
+
new URL(input);
|
|
532
|
+
return true;
|
|
533
|
+
} catch {
|
|
534
|
+
return false;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
export function validateURL(
|
|
539
|
+
trimmed: string,
|
|
540
|
+
def: Pick<$ZodURLDef, "protocol" | "hostname" | "normalize">
|
|
541
|
+
): URL | true | typeof URL_BAD_FORMAT | typeof URL_UNPARSEABLE {
|
|
542
|
+
if (!("normalize" in def) && !("hostname" in def) && !("protocol" in def)) {
|
|
543
|
+
return canParseURL(trimmed) || URL_UNPARSEABLE;
|
|
544
|
+
}
|
|
545
|
+
return parseURLObject(trimmed, def);
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
/** Parses a URL while preserving the non-normalizing HTTP guard. */
|
|
549
|
+
export function parseURLObject(
|
|
550
|
+
trimmed: string,
|
|
551
|
+
def: Pick<$ZodURLDef, "protocol" | "normalize">
|
|
552
|
+
): URL | typeof URL_BAD_FORMAT | typeof URL_UNPARSEABLE {
|
|
553
|
+
// When normalize is off, require :// for http/https URLs. This prevents strings like "http:example.com" or "https:/path" from being silently accepted
|
|
554
|
+
if (!def.normalize && def.protocol?.source === regexes.httpProtocol.source && !/^https?:\/\//i.test(trimmed)) {
|
|
555
|
+
return URL_BAD_FORMAT;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
try {
|
|
559
|
+
if (typeof URL !== "undefined") {
|
|
560
|
+
const URLStatic = URL as typeof URL & { parse?: (input: string) => URL | null };
|
|
561
|
+
if (typeof URLStatic.parse === "function") return URLStatic.parse(trimmed) ?? URL_UNPARSEABLE;
|
|
562
|
+
}
|
|
563
|
+
// @ts-ignore
|
|
564
|
+
return new URL(trimmed);
|
|
565
|
+
} catch {
|
|
566
|
+
return URL_UNPARSEABLE;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
const asciiTabOrNewline = /[\t\n\r]/g;
|
|
571
|
+
|
|
572
|
+
/** The URL parser deletes every ASCII tab, LF and CR from its input before it parses, so `new URL("https://exa\nmple.com")` reports on `example.com`. Applying the same deletion to the returned value closes the half of that divergence which can move the host; the parser's other rewrite, stripping C0 controls at the edges, cannot. */
|
|
573
|
+
export function stripTabAndNewline(value: string): string {
|
|
574
|
+
return value.replace(asciiTabOrNewline, "");
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
export function urlHostnameOk(url: URL, hostname: RegExp): boolean {
|
|
578
|
+
hostname.lastIndex = 0;
|
|
579
|
+
return hostname.test(url.hostname);
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
export function urlProtocolOk(url: URL, protocol: RegExp): boolean {
|
|
583
|
+
protocol.lastIndex = 0;
|
|
584
|
+
return protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol);
|
|
585
|
+
}
|
|
586
|
+
|
|
474
587
|
export const $ZodURL: core.$constructor<$ZodURL> = /*@__PURE__*/ core.$constructor("$ZodURL", (inst, def) => {
|
|
475
588
|
$ZodStringFormat.init(inst, def);
|
|
476
589
|
inst._zod.check = (payload) => {
|
|
477
590
|
try {
|
|
478
591
|
// Trim whitespace from input
|
|
479
592
|
const trimmed = payload.value.trim();
|
|
480
|
-
|
|
481
|
-
const url = new URL(trimmed);
|
|
593
|
+
const url = validateURL(trimmed, def);
|
|
482
594
|
|
|
483
|
-
if (
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
continue: !def.abort,
|
|
494
|
-
});
|
|
495
|
-
}
|
|
595
|
+
if (url === URL_BAD_FORMAT) {
|
|
596
|
+
payload.issues.push({
|
|
597
|
+
code: "invalid_format",
|
|
598
|
+
format: "url",
|
|
599
|
+
note: "Invalid URL format",
|
|
600
|
+
input: payload.value,
|
|
601
|
+
inst,
|
|
602
|
+
continue: !def.abort,
|
|
603
|
+
});
|
|
604
|
+
return;
|
|
496
605
|
}
|
|
497
606
|
|
|
498
|
-
if (
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
inst,
|
|
508
|
-
continue: !def.abort,
|
|
509
|
-
});
|
|
510
|
-
}
|
|
607
|
+
if (url === URL_UNPARSEABLE) {
|
|
608
|
+
payload.issues.push({
|
|
609
|
+
code: "invalid_format",
|
|
610
|
+
format: "url",
|
|
611
|
+
input: payload.value,
|
|
612
|
+
inst,
|
|
613
|
+
continue: !def.abort,
|
|
614
|
+
});
|
|
615
|
+
return;
|
|
511
616
|
}
|
|
512
617
|
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
payload.value = url.href;
|
|
517
|
-
} else {
|
|
518
|
-
// Preserve the original input (trimmed)
|
|
519
|
-
payload.value = trimmed;
|
|
618
|
+
if (url === true) {
|
|
619
|
+
payload.value = stripTabAndNewline(trimmed);
|
|
620
|
+
return;
|
|
520
621
|
}
|
|
521
622
|
|
|
623
|
+
if (def.hostname && !urlHostnameOk(url, def.hostname)) {
|
|
624
|
+
payload.issues.push({
|
|
625
|
+
code: "invalid_format",
|
|
626
|
+
format: "url",
|
|
627
|
+
note: "Invalid hostname",
|
|
628
|
+
pattern: def.hostname.source,
|
|
629
|
+
input: payload.value,
|
|
630
|
+
inst,
|
|
631
|
+
continue: !def.abort,
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
if (def.protocol && !urlProtocolOk(url, def.protocol)) {
|
|
636
|
+
payload.issues.push({
|
|
637
|
+
code: "invalid_format",
|
|
638
|
+
format: "url",
|
|
639
|
+
note: "Invalid protocol",
|
|
640
|
+
pattern: def.protocol.source,
|
|
641
|
+
input: payload.value,
|
|
642
|
+
inst,
|
|
643
|
+
continue: !def.abort,
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
// Set the output value based on normalize flag
|
|
648
|
+
payload.value = def.normalize ? url.href : stripTabAndNewline(trimmed);
|
|
649
|
+
|
|
522
650
|
return;
|
|
523
651
|
} catch (_) {
|
|
524
652
|
payload.issues.push({
|
|
@@ -551,8 +679,12 @@ export const $ZodEmoji: core.$constructor<$ZodEmoji> = /*@__PURE__*/ core.$const
|
|
|
551
679
|
|
|
552
680
|
////////////////////////////// ZodNanoID //////////////////////////////
|
|
553
681
|
|
|
554
|
-
export interface $ZodNanoIDDef extends $ZodStringFormatDef<"nanoid"> {
|
|
555
|
-
|
|
682
|
+
export interface $ZodNanoIDDef extends $ZodStringFormatDef<"nanoid"> {
|
|
683
|
+
length?: number | undefined;
|
|
684
|
+
}
|
|
685
|
+
export interface $ZodNanoIDInternals extends $ZodStringFormatInternals<"nanoid"> {
|
|
686
|
+
def: $ZodNanoIDDef;
|
|
687
|
+
}
|
|
556
688
|
|
|
557
689
|
export interface $ZodNanoID extends $ZodType {
|
|
558
690
|
_zod: $ZodNanoIDInternals;
|
|
@@ -561,20 +693,42 @@ export interface $ZodNanoID extends $ZodType {
|
|
|
561
693
|
export const $ZodNanoID: core.$constructor<$ZodNanoID> = /*@__PURE__*/ core.$constructor(
|
|
562
694
|
"$ZodNanoID",
|
|
563
695
|
(inst, def): void => {
|
|
564
|
-
def.
|
|
696
|
+
if (def.length !== undefined && (!Number.isInteger(def.length) || def.length < 1))
|
|
697
|
+
throw new Error(`Invalid nanoid length: ${def.length}`);
|
|
698
|
+
def.pattern ??= def.length === undefined ? regexes.nanoid : regexes.nanoidOfLength(def.length);
|
|
565
699
|
$ZodStringFormat.init(inst, def);
|
|
566
700
|
}
|
|
567
701
|
);
|
|
568
702
|
|
|
569
703
|
////////////////////////////// ZodCUID //////////////////////////////
|
|
570
704
|
|
|
705
|
+
/**
|
|
706
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
707
|
+
* (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
|
|
708
|
+
* See https://github.com/paralleldrive/cuid.
|
|
709
|
+
*/
|
|
571
710
|
export interface $ZodCUIDDef extends $ZodStringFormatDef<"cuid"> {}
|
|
711
|
+
/**
|
|
712
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
713
|
+
* (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
|
|
714
|
+
* See https://github.com/paralleldrive/cuid.
|
|
715
|
+
*/
|
|
572
716
|
export interface $ZodCUIDInternals extends $ZodStringFormatInternals<"cuid"> {}
|
|
573
717
|
|
|
718
|
+
/**
|
|
719
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
720
|
+
* (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
|
|
721
|
+
* See https://github.com/paralleldrive/cuid.
|
|
722
|
+
*/
|
|
574
723
|
export interface $ZodCUID extends $ZodType {
|
|
575
724
|
_zod: $ZodCUIDInternals;
|
|
576
725
|
}
|
|
577
726
|
|
|
727
|
+
/**
|
|
728
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
729
|
+
* (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
|
|
730
|
+
* See https://github.com/paralleldrive/cuid.
|
|
731
|
+
*/
|
|
578
732
|
export const $ZodCUID: core.$constructor<$ZodCUID> = /*@__PURE__*/ core.$constructor("$ZodCUID", (inst, def): void => {
|
|
579
733
|
def.pattern ??= regexes.cuid;
|
|
580
734
|
$ZodStringFormat.init(inst, def);
|
|
@@ -739,8 +893,6 @@ export interface $ZodIPv4 extends $ZodType {
|
|
|
739
893
|
export const $ZodIPv4: core.$constructor<$ZodIPv4> = /*@__PURE__*/ core.$constructor("$ZodIPv4", (inst, def): void => {
|
|
740
894
|
def.pattern ??= regexes.ipv4;
|
|
741
895
|
$ZodStringFormat.init(inst, def);
|
|
742
|
-
|
|
743
|
-
inst._zod.bag.format = `ipv4`;
|
|
744
896
|
});
|
|
745
897
|
|
|
746
898
|
////////////////////////////// ZodIPv6 //////////////////////////////
|
|
@@ -757,18 +909,20 @@ export interface $ZodIPv6 extends $ZodType {
|
|
|
757
909
|
_zod: $ZodIPv6Internals;
|
|
758
910
|
}
|
|
759
911
|
|
|
912
|
+
/** An IPv6 address is written with hex digits, colons and dots, and nothing else. The guard is what makes the check below an IPv6 check: `new URL("http://[...]")` parses an authority, not an address, so `@` and `\` re-delimit it and `"::@1\\"` validates against the host `0.0.0.1`. The URL parser also deletes ASCII tab, LF and CR rather than failing, which is how `"::1\n"` validated as `::1`. */
|
|
913
|
+
const ipv6Alphabet = /^[0-9a-fA-F:.]+$/;
|
|
914
|
+
|
|
915
|
+
export function isValidIPv6(value: string): boolean {
|
|
916
|
+
if (!ipv6Alphabet.test(value)) return false;
|
|
917
|
+
return canParseURL(`http://[${value}]`);
|
|
918
|
+
}
|
|
919
|
+
|
|
760
920
|
export const $ZodIPv6: core.$constructor<$ZodIPv6> = /*@__PURE__*/ core.$constructor("$ZodIPv6", (inst, def): void => {
|
|
761
921
|
def.pattern ??= regexes.ipv6;
|
|
762
922
|
$ZodStringFormat.init(inst, def);
|
|
763
923
|
|
|
764
|
-
inst._zod.bag.format = `ipv6`;
|
|
765
|
-
|
|
766
924
|
inst._zod.check = (payload) => {
|
|
767
|
-
|
|
768
|
-
// @ts-ignore
|
|
769
|
-
new URL(`http://[${payload.value}]`);
|
|
770
|
-
// return;
|
|
771
|
-
} catch {
|
|
925
|
+
if (!isValidIPv6(payload.value)) {
|
|
772
926
|
payload.issues.push({
|
|
773
927
|
code: "invalid_format",
|
|
774
928
|
format: "ipv6",
|
|
@@ -796,8 +950,6 @@ export interface $ZodMAC extends $ZodType {
|
|
|
796
950
|
export const $ZodMAC: core.$constructor<$ZodMAC> = /*@__PURE__*/ core.$constructor("$ZodMAC", (inst, def): void => {
|
|
797
951
|
def.pattern ??= regexes.mac(def.delimiter);
|
|
798
952
|
$ZodStringFormat.init(inst, def);
|
|
799
|
-
|
|
800
|
-
inst._zod.bag.format = `mac`;
|
|
801
953
|
});
|
|
802
954
|
|
|
803
955
|
////////////////////////////// ZodCIDRv4 //////////////////////////////
|
|
@@ -836,6 +988,17 @@ export interface $ZodCIDRv6 extends $ZodType {
|
|
|
836
988
|
_zod: $ZodCIDRv6Internals;
|
|
837
989
|
}
|
|
838
990
|
|
|
991
|
+
export function isValidCIDRv6(value: string): boolean {
|
|
992
|
+
const parts = value.split("/");
|
|
993
|
+
if (parts.length !== 2) return false;
|
|
994
|
+
const [address, prefix] = parts;
|
|
995
|
+
if (!prefix) return false;
|
|
996
|
+
const prefixNum = Number(prefix);
|
|
997
|
+
if (`${prefixNum}` !== prefix) return false;
|
|
998
|
+
if (prefixNum < 0 || prefixNum > 128) return false;
|
|
999
|
+
return isValidIPv6(address);
|
|
1000
|
+
}
|
|
1001
|
+
|
|
839
1002
|
export const $ZodCIDRv6: core.$constructor<$ZodCIDRv6> = /*@__PURE__*/ core.$constructor(
|
|
840
1003
|
"$ZodCIDRv6",
|
|
841
1004
|
(inst, def): void => {
|
|
@@ -843,17 +1006,7 @@ export const $ZodCIDRv6: core.$constructor<$ZodCIDRv6> = /*@__PURE__*/ core.$con
|
|
|
843
1006
|
$ZodStringFormat.init(inst, def);
|
|
844
1007
|
|
|
845
1008
|
inst._zod.check = (payload) => {
|
|
846
|
-
|
|
847
|
-
try {
|
|
848
|
-
if (parts.length !== 2) throw new Error();
|
|
849
|
-
const [address, prefix] = parts;
|
|
850
|
-
if (!prefix) throw new Error();
|
|
851
|
-
const prefixNum = Number(prefix);
|
|
852
|
-
if (`${prefixNum}` !== prefix) throw new Error();
|
|
853
|
-
if (prefixNum < 0 || prefixNum > 128) throw new Error();
|
|
854
|
-
// @ts-ignore
|
|
855
|
-
new URL(`http://[${address}]`);
|
|
856
|
-
} catch {
|
|
1009
|
+
if (!isValidCIDRv6(payload.value)) {
|
|
857
1010
|
payload.issues.push({
|
|
858
1011
|
code: "invalid_format",
|
|
859
1012
|
format: "cidrv6",
|
|
@@ -869,6 +1022,8 @@ export const $ZodCIDRv6: core.$constructor<$ZodCIDRv6> = /*@__PURE__*/ core.$con
|
|
|
869
1022
|
////////////////////////////// ZodBase64 //////////////////////////////
|
|
870
1023
|
export function isValidBase64(data: string): boolean {
|
|
871
1024
|
if (data === "") return true;
|
|
1025
|
+
// atob ignores whitespace, so reject it up front.
|
|
1026
|
+
if (/\s/.test(data)) return false;
|
|
872
1027
|
if (data.length % 4 !== 0) return false;
|
|
873
1028
|
try {
|
|
874
1029
|
// @ts-ignore
|
|
@@ -886,14 +1041,15 @@ export interface $ZodBase64 extends $ZodType {
|
|
|
886
1041
|
_zod: $ZodBase64Internals;
|
|
887
1042
|
}
|
|
888
1043
|
|
|
1044
|
+
// lax on purpose: the quantified regexes.base64 overflows the regex stack on multi-MB input and its leading ^$| alternation leaks through template-literal composition; isValidBase64 enforces length and padding
|
|
1045
|
+
export const base64Charset: RegExp = /^[0-9a-zA-Z+/]*={0,2}$/;
|
|
1046
|
+
|
|
889
1047
|
export const $ZodBase64: core.$constructor<$ZodBase64> = /*@__PURE__*/ core.$constructor(
|
|
890
1048
|
"$ZodBase64",
|
|
891
1049
|
(inst, def): void => {
|
|
892
|
-
def.pattern ??=
|
|
1050
|
+
def.pattern ??= base64Charset;
|
|
893
1051
|
$ZodStringFormat.init(inst, def);
|
|
894
1052
|
|
|
895
|
-
inst._zod.bag.contentEncoding = "base64";
|
|
896
|
-
|
|
897
1053
|
inst._zod.check = (payload) => {
|
|
898
1054
|
if (isValidBase64(payload.value)) return;
|
|
899
1055
|
|
|
@@ -908,9 +1064,12 @@ export const $ZodBase64: core.$constructor<$ZodBase64> = /*@__PURE__*/ core.$con
|
|
|
908
1064
|
}
|
|
909
1065
|
);
|
|
910
1066
|
|
|
911
|
-
//////////////////////////////
|
|
1067
|
+
////////////////////////////// ZodBase64URL //////////////////////////////
|
|
1068
|
+
// lax on purpose: the quantified regexes.base64url overflows the regex stack on multi-MB input; isValidBase64 enforces length on the padded string
|
|
1069
|
+
export const base64urlCharset: RegExp = /^[A-Za-z0-9_-]*$/;
|
|
1070
|
+
|
|
912
1071
|
export function isValidBase64URL(data: string): boolean {
|
|
913
|
-
if (!
|
|
1072
|
+
if (!base64urlCharset.test(data)) return false;
|
|
914
1073
|
const base64 = data.replace(/[-_]/g, (c) => (c === "-" ? "+" : "/"));
|
|
915
1074
|
const padded = base64.padEnd(Math.ceil(base64.length / 4) * 4, "=");
|
|
916
1075
|
return isValidBase64(padded);
|
|
@@ -926,11 +1085,9 @@ export interface $ZodBase64URL extends $ZodType {
|
|
|
926
1085
|
export const $ZodBase64URL: core.$constructor<$ZodBase64URL> = /*@__PURE__*/ core.$constructor(
|
|
927
1086
|
"$ZodBase64URL",
|
|
928
1087
|
(inst, def): void => {
|
|
929
|
-
def.pattern ??=
|
|
1088
|
+
def.pattern ??= base64urlCharset;
|
|
930
1089
|
$ZodStringFormat.init(inst, def);
|
|
931
1090
|
|
|
932
|
-
inst._zod.bag.contentEncoding = "base64url";
|
|
933
|
-
|
|
934
1091
|
inst._zod.check = (payload) => {
|
|
935
1092
|
if (isValidBase64URL(payload.value)) return;
|
|
936
1093
|
|
|
@@ -959,6 +1116,103 @@ export const $ZodE164: core.$constructor<$ZodE164> = /*@__PURE__*/ core.$constru
|
|
|
959
1116
|
$ZodStringFormat.init(inst, def);
|
|
960
1117
|
});
|
|
961
1118
|
|
|
1119
|
+
////////////////////////////// ZodCreditCard //////////////////////////////
|
|
1120
|
+
|
|
1121
|
+
const CC_SANITIZE = /[- ]/g;
|
|
1122
|
+
|
|
1123
|
+
/** Luhn checksum on a digit-only string. Adapted from valibot (MIT). */
|
|
1124
|
+
function isLuhnAlgo(digits: string): boolean {
|
|
1125
|
+
let length = digits.length;
|
|
1126
|
+
let bit = 1;
|
|
1127
|
+
let sum = 0;
|
|
1128
|
+
while (length) {
|
|
1129
|
+
const value = digits.charCodeAt(--length) - 48;
|
|
1130
|
+
bit ^= 1;
|
|
1131
|
+
sum += bit ? [0, 2, 4, 6, 8, 1, 3, 5, 7, 9][value]! : value;
|
|
1132
|
+
}
|
|
1133
|
+
return sum % 10 === 0;
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
export function isValidCreditCard(input: string): boolean {
|
|
1137
|
+
if (!regexes.creditCard.test(input)) return false;
|
|
1138
|
+
return isLuhnAlgo(input.replace(CC_SANITIZE, ""));
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
export interface $ZodCreditCardDef extends $ZodStringFormatDef<"credit_card"> {}
|
|
1142
|
+
export interface $ZodCreditCardInternals extends $ZodStringFormatInternals<"credit_card"> {
|
|
1143
|
+
def: $ZodCreditCardDef;
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
export interface $ZodCreditCard extends $ZodType {
|
|
1147
|
+
_zod: $ZodCreditCardInternals;
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
export const $ZodCreditCard: core.$constructor<$ZodCreditCard> = /*@__PURE__*/ core.$constructor(
|
|
1151
|
+
"$ZodCreditCard",
|
|
1152
|
+
(inst, def): void => {
|
|
1153
|
+
// Shape only — the Luhn check below is not expressible as a pattern, so consumers of `pattern` (JSON Schema, template literals) get the length and separator rules alone.
|
|
1154
|
+
def.pattern ??= regexes.creditCard;
|
|
1155
|
+
$ZodStringFormat.init(inst, def);
|
|
1156
|
+
inst._zod.check = (payload) => {
|
|
1157
|
+
if (isValidCreditCard(payload.value)) return;
|
|
1158
|
+
payload.issues.push({
|
|
1159
|
+
code: "invalid_format",
|
|
1160
|
+
format: "credit_card",
|
|
1161
|
+
input: payload.value,
|
|
1162
|
+
inst,
|
|
1163
|
+
continue: !def.abort,
|
|
1164
|
+
});
|
|
1165
|
+
};
|
|
1166
|
+
}
|
|
1167
|
+
);
|
|
1168
|
+
|
|
1169
|
+
////////////////////////////// ZodIBAN //////////////////////////////
|
|
1170
|
+
|
|
1171
|
+
// iso 7064 mod 97-10 checksum without BigInt
|
|
1172
|
+
function isIso7064Mod97(iban: string): boolean {
|
|
1173
|
+
let remainder = 0;
|
|
1174
|
+
const len = iban.length;
|
|
1175
|
+
for (let i = 4; i < len; i++) {
|
|
1176
|
+
const code = iban.charCodeAt(i);
|
|
1177
|
+
remainder = (code >= 65 ? remainder * 100 + (code - 55) : remainder * 10 + (code - 48)) % 97;
|
|
1178
|
+
}
|
|
1179
|
+
for (let i = 0; i < 4; i++) {
|
|
1180
|
+
const code = iban.charCodeAt(i);
|
|
1181
|
+
remainder = (code >= 65 ? remainder * 100 + (code - 55) : remainder * 10 + (code - 48)) % 97;
|
|
1182
|
+
}
|
|
1183
|
+
return remainder === 1;
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
export function isValidIBAN(input: string): boolean {
|
|
1187
|
+
if (!regexes.iban.test(input)) return false;
|
|
1188
|
+
return isIso7064Mod97(input);
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
export interface $ZodIBANDef extends $ZodStringFormatDef<"iban"> {}
|
|
1192
|
+
export interface $ZodIBANInternals extends $ZodStringFormatInternals<"iban"> {
|
|
1193
|
+
def: $ZodIBANDef;
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
export interface $ZodIBAN extends $ZodType {
|
|
1197
|
+
_zod: $ZodIBANInternals;
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
export const $ZodIBAN: core.$constructor<$ZodIBAN> = /*@__PURE__*/ core.$constructor("$ZodIBAN", (inst, def): void => {
|
|
1201
|
+
// shape only — checksum is not expressible as a pattern
|
|
1202
|
+
def.pattern ??= regexes.iban;
|
|
1203
|
+
$ZodStringFormat.init(inst, def);
|
|
1204
|
+
inst._zod.check = (payload) => {
|
|
1205
|
+
if (isValidIBAN(payload.value)) return;
|
|
1206
|
+
payload.issues.push({
|
|
1207
|
+
code: "invalid_format",
|
|
1208
|
+
format: "iban",
|
|
1209
|
+
input: payload.value,
|
|
1210
|
+
inst,
|
|
1211
|
+
continue: !def.abort,
|
|
1212
|
+
});
|
|
1213
|
+
};
|
|
1214
|
+
});
|
|
1215
|
+
|
|
962
1216
|
////////////////////////////// ZodJWT //////////////////////////////
|
|
963
1217
|
|
|
964
1218
|
export function isValidJWT(token: string, algorithm: util.JWTAlgorithm | null = null): boolean {
|
|
@@ -1075,7 +1329,7 @@ export interface $ZodNumber<Input = unknown> extends $ZodType {
|
|
|
1075
1329
|
export const $ZodNumber: core.$constructor<$ZodNumber> = /*@__PURE__*/ core.$constructor("$ZodNumber", (inst, def) => {
|
|
1076
1330
|
$ZodType.init(inst, def);
|
|
1077
1331
|
|
|
1078
|
-
inst._zod.pattern =
|
|
1332
|
+
inst._zod.pattern = regexes.number;
|
|
1079
1333
|
inst._zod.parse = (payload, _ctx) => {
|
|
1080
1334
|
if (def.coerce)
|
|
1081
1335
|
try {
|
|
@@ -1091,7 +1345,7 @@ export const $ZodNumber: core.$constructor<$ZodNumber> = /*@__PURE__*/ core.$con
|
|
|
1091
1345
|
? Number.isNaN(input)
|
|
1092
1346
|
? "NaN"
|
|
1093
1347
|
: !Number.isFinite(input)
|
|
1094
|
-
?
|
|
1348
|
+
? String(input)
|
|
1095
1349
|
: undefined
|
|
1096
1350
|
: undefined;
|
|
1097
1351
|
|
|
@@ -1110,15 +1364,19 @@ export const $ZodNumber: core.$constructor<$ZodNumber> = /*@__PURE__*/ core.$con
|
|
|
1110
1364
|
///////////////////////////////////////////////
|
|
1111
1365
|
////////// ZodNumberFormat //////////
|
|
1112
1366
|
///////////////////////////////////////////////
|
|
1113
|
-
export interface $ZodNumberFormatDef extends $
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1367
|
+
export interface $ZodNumberFormatDef<Format extends $ZodNumberFormats = $ZodNumberFormats>
|
|
1368
|
+
extends $ZodNumberDef,
|
|
1369
|
+
checks.$ZodCheckNumberFormatDef<Format> {}
|
|
1370
|
+
|
|
1371
|
+
export interface $ZodNumberFormatInternals<Format extends $ZodNumberFormats = $ZodNumberFormats>
|
|
1372
|
+
extends $ZodNumberInternals<number>,
|
|
1373
|
+
checks.$ZodCheckNumberFormatInternals<Format> {
|
|
1374
|
+
def: $ZodNumberFormatDef<Format>;
|
|
1117
1375
|
isst: errors.$ZodIssueInvalidType;
|
|
1118
1376
|
}
|
|
1119
1377
|
|
|
1120
|
-
export interface $ZodNumberFormat extends $ZodType {
|
|
1121
|
-
_zod: $ZodNumberFormatInternals
|
|
1378
|
+
export interface $ZodNumberFormat<Format extends $ZodNumberFormats = $ZodNumberFormats> extends $ZodType {
|
|
1379
|
+
_zod: $ZodNumberFormatInternals<Format>;
|
|
1122
1380
|
}
|
|
1123
1381
|
|
|
1124
1382
|
export const $ZodNumberFormat: core.$constructor<$ZodNumberFormat> = /*@__PURE__*/ core.$constructor(
|
|
@@ -1233,16 +1491,20 @@ export const $ZodBigInt: core.$constructor<$ZodBigInt> = /*@__PURE__*/ core.$con
|
|
|
1233
1491
|
///////////////////////////////////////////////
|
|
1234
1492
|
////////// ZodBigIntFormat //////////
|
|
1235
1493
|
///////////////////////////////////////////////
|
|
1236
|
-
export interface $ZodBigIntFormatDef extends $
|
|
1494
|
+
export interface $ZodBigIntFormatDef<Format extends $ZodBigIntFormats = $ZodBigIntFormats>
|
|
1495
|
+
extends $ZodBigIntDef,
|
|
1496
|
+
checks.$ZodCheckBigIntFormatDef<Format> {
|
|
1237
1497
|
check: "bigint_format";
|
|
1238
1498
|
}
|
|
1239
1499
|
|
|
1240
|
-
export interface $ZodBigIntFormatInternals extends $
|
|
1241
|
-
|
|
1500
|
+
export interface $ZodBigIntFormatInternals<Format extends $ZodBigIntFormats = $ZodBigIntFormats>
|
|
1501
|
+
extends $ZodBigIntInternals<bigint>,
|
|
1502
|
+
checks.$ZodCheckBigIntFormatInternals<Format> {
|
|
1503
|
+
def: $ZodBigIntFormatDef<Format>;
|
|
1242
1504
|
}
|
|
1243
1505
|
|
|
1244
|
-
export interface $ZodBigIntFormat extends $ZodType {
|
|
1245
|
-
_zod: $ZodBigIntFormatInternals
|
|
1506
|
+
export interface $ZodBigIntFormat<Format extends $ZodBigIntFormats = $ZodBigIntFormats> extends $ZodType {
|
|
1507
|
+
_zod: $ZodBigIntFormatInternals<Format>;
|
|
1246
1508
|
}
|
|
1247
1509
|
|
|
1248
1510
|
export const $ZodBigIntFormat: core.$constructor<$ZodBigIntFormat> = /*@__PURE__*/ core.$constructor(
|
|
@@ -1318,8 +1580,6 @@ export const $ZodUndefined: core.$constructor<$ZodUndefined> = /*@__PURE__*/ cor
|
|
|
1318
1580
|
$ZodType.init(inst, def);
|
|
1319
1581
|
inst._zod.pattern = regexes.undefined;
|
|
1320
1582
|
inst._zod.values = new Set([undefined]);
|
|
1321
|
-
inst._zod.optin = "optional";
|
|
1322
|
-
inst._zod.optout = "optional";
|
|
1323
1583
|
|
|
1324
1584
|
inst._zod.parse = (payload, _ctx) => {
|
|
1325
1585
|
const input = payload.value;
|
|
@@ -1584,6 +1844,34 @@ export interface $ZodArrayInternals<T extends SomeType = $ZodType> extends _$Zod
|
|
|
1584
1844
|
|
|
1585
1845
|
export interface $ZodArray<T extends SomeType = $ZodType> extends $ZodType<any, any, $ZodArrayInternals<T>> {}
|
|
1586
1846
|
|
|
1847
|
+
// an oversized container fails its leading size checks before any element is parsed
|
|
1848
|
+
function capSize(inst: $ZodType, size: (input: any) => number): void {
|
|
1849
|
+
const caps = util.sizeCaps(inst._zod.def.checks);
|
|
1850
|
+
if (!caps.length) return;
|
|
1851
|
+
const cap = Math.min(...caps.map((c) => c[0]));
|
|
1852
|
+
const parse = inst._zod.parse;
|
|
1853
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1854
|
+
const n = size(payload.value);
|
|
1855
|
+
if (n > cap && !ctx?.skipChecks && ctx?.direction !== "backward") {
|
|
1856
|
+
for (const [max, ch] of util.sizeCaps(inst._zod.def.checks)) {
|
|
1857
|
+
if (n > max && ch._zod.def.when!(payload)) {
|
|
1858
|
+
const start = payload.issues.length;
|
|
1859
|
+
ch._zod.check(payload as ParsePayload<never>);
|
|
1860
|
+
// the value is still the raw input, so no later check may read it
|
|
1861
|
+
(payload.issues[start] as { continue?: boolean }).continue = false;
|
|
1862
|
+
util.attachSchema(payload.issues, start, inst);
|
|
1863
|
+
return payload;
|
|
1864
|
+
}
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1867
|
+
return parse(payload, ctx);
|
|
1868
|
+
};
|
|
1869
|
+
}
|
|
1870
|
+
|
|
1871
|
+
const arraySize = (input: unknown): number => (Array.isArray(input) ? input.length : -1);
|
|
1872
|
+
const mapSize = (input: unknown): number => (input instanceof Map ? input.size : -1);
|
|
1873
|
+
const setSize = (input: unknown): number => (input instanceof Set ? input.size : -1);
|
|
1874
|
+
|
|
1587
1875
|
function handleArrayResult(result: ParsePayload<any>, final: ParsePayload<any[]>, index: number) {
|
|
1588
1876
|
if (result.issues.length) {
|
|
1589
1877
|
final.issues.push(...util.prefixIssues(index, result.issues));
|
|
@@ -1594,6 +1882,9 @@ function handleArrayResult(result: ParsePayload<any>, final: ParsePayload<any[]>
|
|
|
1594
1882
|
export const $ZodArray: core.$constructor<$ZodArray> = /*@__PURE__*/ core.$constructor("$ZodArray", (inst, def) => {
|
|
1595
1883
|
$ZodType.init(inst, def);
|
|
1596
1884
|
|
|
1885
|
+
const memo = core.globalConfig.memoizer;
|
|
1886
|
+
memo?.attach(inst);
|
|
1887
|
+
|
|
1597
1888
|
inst._zod.parse = (payload, ctx) => {
|
|
1598
1889
|
const input = payload.value;
|
|
1599
1890
|
|
|
@@ -1608,8 +1899,9 @@ export const $ZodArray: core.$constructor<$ZodArray> = /*@__PURE__*/ core.$const
|
|
|
1608
1899
|
return payload;
|
|
1609
1900
|
}
|
|
1610
1901
|
|
|
1611
|
-
payload.value = Array(input.length);
|
|
1902
|
+
payload.value = memo ? memo.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
|
|
1612
1903
|
const proms: Promise<any>[] = [];
|
|
1904
|
+
const abortEarly = ctx?.abortEarly;
|
|
1613
1905
|
for (let i = 0; i < input.length; i++) {
|
|
1614
1906
|
const item = input[i];
|
|
1615
1907
|
const result = def.element._zod.run(
|
|
@@ -1624,6 +1916,8 @@ export const $ZodArray: core.$constructor<$ZodArray> = /*@__PURE__*/ core.$const
|
|
|
1624
1916
|
proms.push(result.then((result) => handleArrayResult(result, payload, i)));
|
|
1625
1917
|
} else {
|
|
1626
1918
|
handleArrayResult(result, payload, i);
|
|
1919
|
+
// the element's payload is authoritative here, since handleArrayResult forwards every issue; an object's is not, because it drops a failed absent optional
|
|
1920
|
+
if (abortEarly && result.issues.length !== 0 && util.aborted(result)) break;
|
|
1627
1921
|
}
|
|
1628
1922
|
}
|
|
1629
1923
|
|
|
@@ -1633,6 +1927,7 @@ export const $ZodArray: core.$constructor<$ZodArray> = /*@__PURE__*/ core.$const
|
|
|
1633
1927
|
|
|
1634
1928
|
return payload; //handleArrayResultsAsync(parseResults, final);
|
|
1635
1929
|
};
|
|
1930
|
+
capSize(inst, arraySize);
|
|
1636
1931
|
});
|
|
1637
1932
|
|
|
1638
1933
|
//////////////////////////////////////////
|
|
@@ -1644,12 +1939,12 @@ export const $ZodArray: core.$constructor<$ZodArray> = /*@__PURE__*/ core.$const
|
|
|
1644
1939
|
//////////////////////////////////////////
|
|
1645
1940
|
|
|
1646
1941
|
type OptionalOutSchema = { _zod: { optout: "optional" } };
|
|
1647
|
-
type OptionalInSchema = { _zod: { optin: "optional" } };
|
|
1942
|
+
type OptionalInSchema = { _zod: { optin: "optional" | "defaulted" } };
|
|
1648
1943
|
|
|
1649
1944
|
export type $InferObjectOutput<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = string extends keyof T
|
|
1650
1945
|
? util.IsAny<T[keyof T]> extends true
|
|
1651
1946
|
? Record<string, unknown>
|
|
1652
|
-
:
|
|
1947
|
+
: { [k in string]: core.output<T[keyof T]> }
|
|
1653
1948
|
: keyof (T & Extra) extends never
|
|
1654
1949
|
? Record<string, never>
|
|
1655
1950
|
: util.Prettify<
|
|
@@ -1693,7 +1988,7 @@ export type $InferObjectOutput<T extends $ZodLooseShape, Extra extends Record<st
|
|
|
1693
1988
|
export type $InferObjectInput<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = string extends keyof T
|
|
1694
1989
|
? util.IsAny<T[keyof T]> extends true
|
|
1695
1990
|
? Record<string, unknown>
|
|
1696
|
-
:
|
|
1991
|
+
: { [k in string]: core.input<T[keyof T]> }
|
|
1697
1992
|
: keyof (T & Extra) extends never
|
|
1698
1993
|
? Record<string, never>
|
|
1699
1994
|
: util.Prettify<
|
|
@@ -1709,18 +2004,37 @@ function handlePropertyResult(
|
|
|
1709
2004
|
final: ParsePayload,
|
|
1710
2005
|
key: PropertyKey,
|
|
1711
2006
|
input: any,
|
|
1712
|
-
|
|
2007
|
+
optin: "optional" | "defaulted" | undefined,
|
|
2008
|
+
optout: "optional" | undefined
|
|
1713
2009
|
) {
|
|
2010
|
+
const isPresent = key in input;
|
|
2011
|
+
const isOptionalOut = optout === "optional";
|
|
2012
|
+
// The middle rung means "absence permitted, nothing supplied in its place", so an absent key contributes nothing — whatever the schema made of `undefined` is invented, not substituted. Only `optional` reaches this with a value: `defaulted` substitutes, and a schema that isn't optional-out has to keep the key.
|
|
2013
|
+
if (!isPresent && isOptionalOut && optin === "optional") {
|
|
2014
|
+
return;
|
|
2015
|
+
}
|
|
1714
2016
|
if (result.issues.length) {
|
|
1715
|
-
// For optional-out schemas, ignore errors on absent keys
|
|
1716
|
-
if (isOptionalOut && !
|
|
2017
|
+
// For optional-in/out schemas, ignore errors on absent keys.
|
|
2018
|
+
if (optin !== undefined && isOptionalOut && !isPresent) {
|
|
1717
2019
|
return;
|
|
1718
2020
|
}
|
|
1719
2021
|
final.issues.push(...util.prefixIssues(key, result.issues));
|
|
1720
2022
|
}
|
|
1721
2023
|
|
|
2024
|
+
if (!isPresent && optin === undefined) {
|
|
2025
|
+
if (!result.issues.length) {
|
|
2026
|
+
final.issues.push({
|
|
2027
|
+
code: "invalid_type",
|
|
2028
|
+
expected: "nonoptional",
|
|
2029
|
+
input: undefined,
|
|
2030
|
+
path: [key],
|
|
2031
|
+
});
|
|
2032
|
+
}
|
|
2033
|
+
return;
|
|
2034
|
+
}
|
|
2035
|
+
|
|
1722
2036
|
if (result.value === undefined) {
|
|
1723
|
-
if (
|
|
2037
|
+
if (isPresent || (optin === "defaulted" && !isOptionalOut)) {
|
|
1724
2038
|
(final.value as any)[key] = undefined;
|
|
1725
2039
|
}
|
|
1726
2040
|
} else {
|
|
@@ -1778,18 +2092,27 @@ export interface $ZodObject<
|
|
|
1778
2092
|
out Params extends $ZodObjectConfig = $ZodObjectConfig,
|
|
1779
2093
|
> extends $ZodType<any, any, $ZodObjectInternals<Shape, Params>> {}
|
|
1780
2094
|
|
|
2095
|
+
// one shared instance; a fresh [] per schema cost 56 bytes retained
|
|
2096
|
+
const NO_SYMBOL_KEYS: symbol[] = [];
|
|
2097
|
+
|
|
1781
2098
|
function normalizeDef(def: $ZodObjectDef) {
|
|
1782
2099
|
const keys = Object.keys(def.shape);
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
2100
|
+
const ownSymbols = Object.getOwnPropertySymbols(def.shape);
|
|
2101
|
+
const symbolKeys = ownSymbols.length ? ownSymbols : NO_SYMBOL_KEYS;
|
|
2102
|
+
// aliases `keys` when there are no symbols, so a string-only shape keeps one array
|
|
2103
|
+
const allKeys: (string | symbol)[] = symbolKeys.length ? [...keys, ...symbolKeys] : keys;
|
|
2104
|
+
for (const k of allKeys) {
|
|
2105
|
+
if (!(def.shape as any)?.[k]?._zod?.traits?.has("$ZodType")) {
|
|
2106
|
+
throw new Error(`Invalid element at key "${String(k)}": expected a Zod schema`);
|
|
1786
2107
|
}
|
|
1787
2108
|
}
|
|
1788
2109
|
const okeys = util.optionalKeys(def.shape);
|
|
1789
2110
|
|
|
1790
2111
|
return {
|
|
1791
2112
|
...def,
|
|
1792
|
-
|
|
2113
|
+
allKeys,
|
|
2114
|
+
symbolKeys,
|
|
2115
|
+
// string-only: handleCatchall matches it against `for...in`, which never yields a symbol
|
|
1793
2116
|
keySet: new Set(keys),
|
|
1794
2117
|
numKeys: keys.length,
|
|
1795
2118
|
optionalKeys: new Set(okeys),
|
|
@@ -1800,18 +2123,31 @@ function handleCatchall(
|
|
|
1800
2123
|
proms: Promise<any>[],
|
|
1801
2124
|
input: any,
|
|
1802
2125
|
payload: ParsePayload,
|
|
1803
|
-
ctx:
|
|
2126
|
+
ctx: ParseContextInternal,
|
|
1804
2127
|
def: ReturnType<typeof normalizeDef>,
|
|
1805
|
-
inst: $ZodObject
|
|
2128
|
+
inst: $ZodObject,
|
|
2129
|
+
abortEarly: boolean
|
|
1806
2130
|
) {
|
|
1807
2131
|
const unrecognized: string[] = [];
|
|
1808
|
-
// iterate over input keys
|
|
1809
2132
|
const keySet = def.keySet;
|
|
1810
2133
|
const _catchall = def.catchall!._zod;
|
|
1811
2134
|
const t = _catchall.def.type;
|
|
1812
|
-
const
|
|
2135
|
+
const optin = _catchall.optin;
|
|
2136
|
+
const optout = _catchall.optout;
|
|
2137
|
+
// starts at 0, not the current length: the shape phase already ran and may have aborted
|
|
2138
|
+
let seen = 0;
|
|
1813
2139
|
for (const key in input) {
|
|
2140
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
2141
|
+
if (util.aborted(payload, seen)) break;
|
|
2142
|
+
seen = payload.issues.length;
|
|
2143
|
+
}
|
|
2144
|
+
// Must precede the __proto__ branch: a declared key is not unrecognized, even though the shape loop deliberately strips __proto__ from the parsed output.
|
|
1814
2145
|
if (keySet.has(key)) continue;
|
|
2146
|
+
// Don't copy an undeclared __proto__ into the result; assignment to a plain {} would replace the result prototype. But in strict mode it is still an unknown key, so report it before skipping.
|
|
2147
|
+
if (key === "__proto__") {
|
|
2148
|
+
if (t === "never") unrecognized.push(key);
|
|
2149
|
+
continue;
|
|
2150
|
+
}
|
|
1815
2151
|
if (t === "never") {
|
|
1816
2152
|
unrecognized.push(key);
|
|
1817
2153
|
continue;
|
|
@@ -1819,9 +2155,9 @@ function handleCatchall(
|
|
|
1819
2155
|
const r = _catchall.run({ value: input[key], issues: [] }, ctx);
|
|
1820
2156
|
|
|
1821
2157
|
if (r instanceof Promise) {
|
|
1822
|
-
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input,
|
|
2158
|
+
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
|
|
1823
2159
|
} else {
|
|
1824
|
-
handlePropertyResult(r, payload, key, input,
|
|
2160
|
+
handlePropertyResult(r, payload, key, input, optin, optout);
|
|
1825
2161
|
}
|
|
1826
2162
|
}
|
|
1827
2163
|
|
|
@@ -1831,6 +2167,8 @@ function handleCatchall(
|
|
|
1831
2167
|
keys: unrecognized,
|
|
1832
2168
|
input,
|
|
1833
2169
|
inst,
|
|
2170
|
+
// Describes the shape of the input, not the validity of the parsed value, so it never aborts. The parse still fails; the schema's own checks just get to run first, and an enclosing intersection can reconcile the key against a sibling operand.
|
|
2171
|
+
continue: true,
|
|
1834
2172
|
});
|
|
1835
2173
|
}
|
|
1836
2174
|
|
|
@@ -1843,32 +2181,35 @@ function handleCatchall(
|
|
|
1843
2181
|
export const $ZodObject: core.$constructor<$ZodObject> = /*@__PURE__*/ core.$constructor("$ZodObject", (inst, def) => {
|
|
1844
2182
|
// requires cast because technically $ZodObject doesn't extend
|
|
1845
2183
|
$ZodType.init(inst, def);
|
|
1846
|
-
// const sh = def.shape;
|
|
1847
2184
|
const desc = Object.getOwnPropertyDescriptor(def, "shape");
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
});
|
|
2185
|
+
// a cloned def carries its source's accessor, which knows the shape it answers from; adopting that keeps the clone's keys readable without running it
|
|
2186
|
+
const sh = desc?.get ? (desc.get as util.ShapeGetter).raw : (def.shape ?? {});
|
|
2187
|
+
if (sh) {
|
|
2188
|
+
// Freezes the shape on first read, so its getters resolve once and every later read sees the same schemas.
|
|
2189
|
+
const get: util.ShapeGetter = () => {
|
|
2190
|
+
const newSh = { ...sh };
|
|
2191
|
+
Object.defineProperty(def, "shape", { value: newSh });
|
|
2192
|
+
get.raw = newSh;
|
|
2193
|
+
return newSh;
|
|
2194
|
+
};
|
|
2195
|
+
get.raw = sh;
|
|
2196
|
+
Object.defineProperty(def, "shape", { get });
|
|
1860
2197
|
}
|
|
1861
2198
|
|
|
1862
2199
|
const _normalized = util.cached(() => normalizeDef(def));
|
|
1863
2200
|
|
|
1864
|
-
util.
|
|
1865
|
-
const shape = def.shape;
|
|
2201
|
+
util.defineLazyInternal(inst, "propValues", (zod) => {
|
|
2202
|
+
const shape = zod.def.shape;
|
|
1866
2203
|
const propValues: util.PropValues = {};
|
|
1867
2204
|
for (const key in shape) {
|
|
1868
2205
|
const field = shape[key]!._zod;
|
|
1869
2206
|
if (field.values) {
|
|
1870
|
-
propValues
|
|
2207
|
+
if (!Object.prototype.hasOwnProperty.call(propValues, key)) {
|
|
2208
|
+
util.assignProp(propValues, key, new Set());
|
|
2209
|
+
}
|
|
1871
2210
|
for (const v of field.values) propValues[key].add(v);
|
|
2211
|
+
// An omittable slot reads back as undefined at a discriminator lookup, so it has to claim undefined: two options that can both omit the key are not discriminable on it.
|
|
2212
|
+
if (field.optin !== undefined) propValues[key].add(undefined);
|
|
1872
2213
|
}
|
|
1873
2214
|
}
|
|
1874
2215
|
return propValues;
|
|
@@ -1878,6 +2219,8 @@ export const $ZodObject: core.$constructor<$ZodObject> = /*@__PURE__*/ core.$con
|
|
|
1878
2219
|
const catchall = def.catchall;
|
|
1879
2220
|
|
|
1880
2221
|
let value!: typeof _normalized.value;
|
|
2222
|
+
const memo = core.globalConfig.memoizer;
|
|
2223
|
+
memo?.attach(inst);
|
|
1881
2224
|
|
|
1882
2225
|
inst._zod.parse = (payload, ctx) => {
|
|
1883
2226
|
value ??= _normalized.value;
|
|
@@ -1892,20 +2235,28 @@ export const $ZodObject: core.$constructor<$ZodObject> = /*@__PURE__*/ core.$con
|
|
|
1892
2235
|
return payload;
|
|
1893
2236
|
}
|
|
1894
2237
|
|
|
1895
|
-
payload.value = {};
|
|
2238
|
+
payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
|
|
1896
2239
|
|
|
1897
2240
|
const proms: Promise<any>[] = [];
|
|
1898
2241
|
const shape = value.shape;
|
|
2242
|
+
const abortEarly = ctx?.abortEarly;
|
|
2243
|
+
let seen = payload.issues.length;
|
|
1899
2244
|
|
|
1900
|
-
for (const key of value.
|
|
1901
|
-
|
|
1902
|
-
|
|
2245
|
+
for (const key of value.allKeys) {
|
|
2246
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
2247
|
+
if (util.aborted(payload, seen)) break;
|
|
2248
|
+
seen = payload.issues.length;
|
|
2249
|
+
}
|
|
2250
|
+
if (key === "__proto__") continue;
|
|
2251
|
+
const el = (shape as any)[key]!;
|
|
2252
|
+
const optin = el._zod.optin;
|
|
2253
|
+
const optout = el._zod.optout;
|
|
1903
2254
|
|
|
1904
2255
|
const r = el._zod.run({ value: input[key], issues: [] }, ctx);
|
|
1905
2256
|
if (r instanceof Promise) {
|
|
1906
|
-
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input,
|
|
2257
|
+
proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
|
|
1907
2258
|
} else {
|
|
1908
|
-
handlePropertyResult(r, payload, key, input,
|
|
2259
|
+
handlePropertyResult(r, payload, key, input, optin, optout);
|
|
1909
2260
|
}
|
|
1910
2261
|
}
|
|
1911
2262
|
|
|
@@ -1913,7 +2264,7 @@ export const $ZodObject: core.$constructor<$ZodObject> = /*@__PURE__*/ core.$con
|
|
|
1913
2264
|
return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
|
1914
2265
|
}
|
|
1915
2266
|
|
|
1916
|
-
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
|
|
2267
|
+
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst, abortEarly === true);
|
|
1917
2268
|
};
|
|
1918
2269
|
});
|
|
1919
2270
|
|
|
@@ -1926,79 +2277,111 @@ export const $ZodObjectJIT: core.$constructor<$ZodObject> = /*@__PURE__*/ core.$
|
|
|
1926
2277
|
const superParse = inst._zod.parse;
|
|
1927
2278
|
const _normalized = util.cached(() => normalizeDef(def));
|
|
1928
2279
|
|
|
2280
|
+
const memo = core.globalConfig.memoizer;
|
|
2281
|
+
|
|
1929
2282
|
const generateFastpass = (shape: any) => {
|
|
1930
|
-
const doc = new Doc(["shape", "payload", "ctx"]);
|
|
1931
2283
|
const normalized = _normalized.value;
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
}
|
|
2284
|
+
const syms = normalized.symbolKeys;
|
|
2285
|
+
// a symbol has no source literal, so it is read as `syms[i]` off the closed-over scope
|
|
2286
|
+
const doc = new Doc(["payload", "ctx"], { shape, inst, memo, syms });
|
|
2287
|
+
|
|
2288
|
+
const parseStr = (k: string) => `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
|
|
2289
|
+
|
|
2290
|
+
// prefixes in place, like util.prefixIssues. newResult must land before the early return: a catchall runs after this and would otherwise write onto the caller's input
|
|
2291
|
+
const prefixStr = (id: string, k: string) => `
|
|
2292
|
+
let ${id}_ab = false;
|
|
2293
|
+
for (let i = 0; i < ${id}.issues.length; i++) {
|
|
2294
|
+
const iss = ${id}.issues[i];
|
|
2295
|
+
iss.path = iss.path ? [${k}, ...iss.path] : [${k}];
|
|
2296
|
+
payload.issues.push(iss);
|
|
2297
|
+
if (iss.continue !== true) ${id}_ab = true;
|
|
2298
|
+
}
|
|
2299
|
+
if (${id}_ab && ctx && ctx.abortEarly) {
|
|
2300
|
+
payload.value = newResult;
|
|
2301
|
+
return payload;
|
|
2302
|
+
}`;
|
|
1937
2303
|
|
|
1938
2304
|
doc.write(`const input = payload.value;`);
|
|
1939
2305
|
|
|
1940
2306
|
const ids: any = Object.create(null);
|
|
1941
2307
|
let counter = 0;
|
|
1942
|
-
for (const key of normalized.
|
|
2308
|
+
for (const key of normalized.allKeys) {
|
|
1943
2309
|
ids[key] = `key_${counter++}`;
|
|
1944
2310
|
}
|
|
1945
2311
|
|
|
1946
2312
|
// A: preserve key order {
|
|
1947
|
-
doc.write(`const newResult = {};`);
|
|
1948
|
-
for (const key of normalized.
|
|
2313
|
+
doc.write(memo ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
|
|
2314
|
+
for (const key of normalized.allKeys) {
|
|
2315
|
+
if (key === "__proto__") continue;
|
|
1949
2316
|
const id = ids[key];
|
|
1950
|
-
const k = util.esc(key);
|
|
2317
|
+
const k = typeof key === "symbol" ? `syms[${syms.indexOf(key)}]` : util.esc(key);
|
|
2318
|
+
const isPresent = `${k} in input`;
|
|
1951
2319
|
const schema = shape[key];
|
|
2320
|
+
const optin = schema?._zod?.optin;
|
|
2321
|
+
const isOptionalIn = optin !== undefined;
|
|
1952
2322
|
const isOptionalOut = schema?._zod?.optout === "optional";
|
|
1953
2323
|
|
|
1954
|
-
doc.write(`const ${id} = ${parseStr(
|
|
2324
|
+
doc.write(`const ${id} = ${parseStr(k)};`);
|
|
1955
2325
|
|
|
1956
|
-
if (isOptionalOut) {
|
|
1957
|
-
// For optional-out schemas, ignore errors on absent keys
|
|
2326
|
+
if (isOptionalIn && isOptionalOut) {
|
|
2327
|
+
// For optional-in/out schemas, ignore errors on absent keys — and, like the interpreted path, drop the value produced alongside them. The middle rung goes further: it permits absence without supplying anything in its place, so an absent key contributes nothing at all.
|
|
2328
|
+
const assign = optin === "optional" ? `${id}_present` : `${id}.value !== undefined || ${id}_present`;
|
|
1958
2329
|
doc.write(`
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
2330
|
+
const ${id}_present = ${isPresent};
|
|
2331
|
+
if (!${id}.issues.length || ${id}_present) {
|
|
2332
|
+
if (${id}.issues.length) {${prefixStr(id, k)}
|
|
2333
|
+
}
|
|
2334
|
+
|
|
2335
|
+
if (${assign}) {
|
|
2336
|
+
newResult[${k}] = ${id}.value;
|
|
1965
2337
|
}
|
|
1966
2338
|
}
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
2339
|
+
|
|
2340
|
+
`);
|
|
2341
|
+
} else if (!isOptionalIn) {
|
|
2342
|
+
doc.write(`
|
|
2343
|
+
const ${id}_present = ${isPresent};
|
|
2344
|
+
if (${id}.issues.length) {${prefixStr(id, k)}
|
|
2345
|
+
}
|
|
2346
|
+
if (!${id}_present && !${id}.issues.length) {
|
|
2347
|
+
payload.issues.push({
|
|
2348
|
+
code: "invalid_type",
|
|
2349
|
+
expected: "nonoptional",
|
|
2350
|
+
input: undefined,
|
|
2351
|
+
path: [${k}]
|
|
2352
|
+
});
|
|
2353
|
+
if (ctx && ctx.abortEarly) {
|
|
2354
|
+
payload.value = newResult;
|
|
2355
|
+
return payload;
|
|
1971
2356
|
}
|
|
1972
|
-
}
|
|
2357
|
+
}
|
|
2358
|
+
|
|
2359
|
+
if (${id}_present) {
|
|
1973
2360
|
newResult[${k}] = ${id}.value;
|
|
1974
2361
|
}
|
|
1975
|
-
|
|
2362
|
+
|
|
1976
2363
|
`);
|
|
1977
2364
|
} else {
|
|
1978
2365
|
doc.write(`
|
|
1979
|
-
if (${id}.issues.length) {
|
|
1980
|
-
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
1981
|
-
...iss,
|
|
1982
|
-
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
1983
|
-
})));
|
|
2366
|
+
if (${id}.issues.length) {${prefixStr(id, k)}
|
|
1984
2367
|
}
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
}
|
|
2368
|
+
`);
|
|
2369
|
+
if (optin === "defaulted") {
|
|
2370
|
+
doc.write(`newResult[${k}] = ${id}.value;`);
|
|
2371
|
+
} else {
|
|
2372
|
+
doc.write(`
|
|
2373
|
+
if (${id}.value !== undefined || ${isPresent}) {
|
|
1991
2374
|
newResult[${k}] = ${id}.value;
|
|
1992
2375
|
}
|
|
1993
|
-
|
|
1994
2376
|
`);
|
|
2377
|
+
}
|
|
1995
2378
|
}
|
|
1996
2379
|
}
|
|
1997
2380
|
|
|
1998
2381
|
doc.write(`payload.value = newResult;`);
|
|
1999
2382
|
doc.write(`return payload;`);
|
|
2000
|
-
|
|
2001
|
-
return (payload: any, ctx: any) =>
|
|
2383
|
+
// closing `shape` in is what pays: turbofan specializes the parser against that one shape object, so every `shape[k]._zod.run` folds to a known callee. as a parameter it stays a generic load and measures 13% slower even with the forwarding frame gone
|
|
2384
|
+
return doc.compile() as (payload: any, ctx: any) => any;
|
|
2002
2385
|
};
|
|
2003
2386
|
|
|
2004
2387
|
let fastpass!: ReturnType<typeof generateFastpass>;
|
|
@@ -2031,7 +2414,7 @@ export const $ZodObjectJIT: core.$constructor<$ZodObject> = /*@__PURE__*/ core.$
|
|
|
2031
2414
|
payload = fastpass(payload, ctx);
|
|
2032
2415
|
|
|
2033
2416
|
if (!catchall) return payload;
|
|
2034
|
-
return handleCatchall([], input, payload, ctx, value, inst);
|
|
2417
|
+
return handleCatchall([], input, payload, ctx, value, inst, ctx?.abortEarly === true);
|
|
2035
2418
|
}
|
|
2036
2419
|
|
|
2037
2420
|
return superParse(payload, ctx);
|
|
@@ -2066,7 +2449,7 @@ export interface $ZodUnionInternals<T extends readonly SomeType[] = readonly $Zo
|
|
|
2066
2449
|
output: $InferUnionOutput<T[number]>;
|
|
2067
2450
|
input: $InferUnionInput<T[number]>;
|
|
2068
2451
|
// if any element in the union is optional, then the union is optional
|
|
2069
|
-
optin: IsOptionalIn<T[number]> extends false ? "optional" | undefined : "optional";
|
|
2452
|
+
optin: IsOptionalIn<T[number]> extends false ? "optional" | "defaulted" | undefined : "optional" | "defaulted";
|
|
2070
2453
|
optout: IsOptionalOut<T[number]> extends false ? "optional" | undefined : "optional";
|
|
2071
2454
|
}
|
|
2072
2455
|
|
|
@@ -2103,34 +2486,37 @@ function handleUnionResults(results: ParsePayload[], final: ParsePayload, inst:
|
|
|
2103
2486
|
export const $ZodUnion: core.$constructor<$ZodUnion> = /*@__PURE__*/ core.$constructor("$ZodUnion", (inst, def) => {
|
|
2104
2487
|
$ZodType.init(inst, def);
|
|
2105
2488
|
|
|
2106
|
-
util.
|
|
2107
|
-
def.options.some((o) => o._zod.optin === "
|
|
2489
|
+
util.defineLazyInternal(inst, "optin", (zod) =>
|
|
2490
|
+
zod.def.options.some((o) => o._zod.optin === "defaulted")
|
|
2491
|
+
? "defaulted"
|
|
2492
|
+
: zod.def.options.some((o) => o._zod.optin !== undefined)
|
|
2493
|
+
? "optional"
|
|
2494
|
+
: undefined
|
|
2108
2495
|
);
|
|
2109
2496
|
|
|
2110
|
-
util.
|
|
2111
|
-
def.options.some((o) => o._zod.optout === "optional") ? "optional" : undefined
|
|
2497
|
+
util.defineLazyInternal(inst, "optout", (zod) =>
|
|
2498
|
+
zod.def.options.some((o) => o._zod.optout === "optional") ? "optional" : undefined
|
|
2112
2499
|
);
|
|
2113
2500
|
|
|
2114
|
-
util.
|
|
2115
|
-
if (def.options.every((o) => o._zod.values)) {
|
|
2116
|
-
return new Set<util.Primitive>(def.options.flatMap((option) => Array.from(option._zod.values!)));
|
|
2501
|
+
util.defineLazyInternal(inst, "values", (zod) => {
|
|
2502
|
+
if (zod.def.options.every((o) => o._zod.values)) {
|
|
2503
|
+
return new Set<util.Primitive>(zod.def.options.flatMap((option) => Array.from(option._zod.values!)));
|
|
2117
2504
|
}
|
|
2118
2505
|
return undefined;
|
|
2119
2506
|
});
|
|
2120
2507
|
|
|
2121
|
-
util.
|
|
2122
|
-
if (def.options.every((o) => o._zod.pattern)) {
|
|
2123
|
-
const patterns = def.options.map((o) => o._zod.pattern);
|
|
2508
|
+
util.defineLazyInternal(inst, "pattern", (zod) => {
|
|
2509
|
+
if (zod.def.options.every((o) => o._zod.pattern)) {
|
|
2510
|
+
const patterns = zod.def.options.map((o) => o._zod.pattern);
|
|
2124
2511
|
return new RegExp(`^(${patterns.map((p) => util.cleanRegex(p!.source)).join("|")})$`);
|
|
2125
2512
|
}
|
|
2126
2513
|
return undefined;
|
|
2127
2514
|
});
|
|
2128
2515
|
|
|
2129
|
-
const
|
|
2130
|
-
const first = def.options[0]._zod.run;
|
|
2516
|
+
const first = def.options.length === 1 ? def.options[0]._zod.run : null;
|
|
2131
2517
|
|
|
2132
2518
|
inst._zod.parse = (payload, ctx) => {
|
|
2133
|
-
if (
|
|
2519
|
+
if (first) {
|
|
2134
2520
|
return first(payload, ctx);
|
|
2135
2521
|
}
|
|
2136
2522
|
let async = false;
|
|
@@ -2166,14 +2552,17 @@ function handleExclusiveUnionResults(
|
|
|
2166
2552
|
inst: $ZodUnion,
|
|
2167
2553
|
ctx?: ParseContext
|
|
2168
2554
|
) {
|
|
2169
|
-
const
|
|
2555
|
+
const matches: number[] = [];
|
|
2556
|
+
for (let i = 0; i < results.length; i++) {
|
|
2557
|
+
if (results[i].issues.length === 0) matches.push(i);
|
|
2558
|
+
}
|
|
2170
2559
|
|
|
2171
|
-
if (
|
|
2172
|
-
final.value =
|
|
2560
|
+
if (matches.length === 1) {
|
|
2561
|
+
final.value = results[matches[0]].value;
|
|
2173
2562
|
return final;
|
|
2174
2563
|
}
|
|
2175
2564
|
|
|
2176
|
-
if (
|
|
2565
|
+
if (matches.length === 0) {
|
|
2177
2566
|
// No matches - same as regular union
|
|
2178
2567
|
final.issues.push({
|
|
2179
2568
|
code: "invalid_union",
|
|
@@ -2189,6 +2578,7 @@ function handleExclusiveUnionResults(
|
|
|
2189
2578
|
inst,
|
|
2190
2579
|
errors: [],
|
|
2191
2580
|
inclusive: false,
|
|
2581
|
+
matches,
|
|
2192
2582
|
});
|
|
2193
2583
|
}
|
|
2194
2584
|
|
|
@@ -2206,11 +2596,10 @@ export const $ZodXor: core.$constructor<$ZodXor> = /*@__PURE__*/ core.$construct
|
|
|
2206
2596
|
$ZodUnion.init(inst, def);
|
|
2207
2597
|
def.inclusive = false;
|
|
2208
2598
|
|
|
2209
|
-
const
|
|
2210
|
-
const first = def.options[0]._zod.run;
|
|
2599
|
+
const first = def.options.length === 1 ? def.options[0]._zod.run : null;
|
|
2211
2600
|
|
|
2212
2601
|
inst._zod.parse = (payload, ctx) => {
|
|
2213
|
-
if (
|
|
2602
|
+
if (first) {
|
|
2214
2603
|
return first(payload, ctx);
|
|
2215
2604
|
}
|
|
2216
2605
|
let async = false;
|
|
@@ -2261,6 +2650,65 @@ export interface $ZodDiscriminatedUnionInternals<
|
|
|
2261
2650
|
> extends $ZodUnionInternals<Options> {
|
|
2262
2651
|
def: $ZodDiscriminatedUnionDef<Options, Disc>;
|
|
2263
2652
|
propValues: util.PropValues;
|
|
2653
|
+
bag: util.LoosePartial<{
|
|
2654
|
+
optionsMap: Map<util.Primitive, $ZodType | null>;
|
|
2655
|
+
}>;
|
|
2656
|
+
}
|
|
2657
|
+
|
|
2658
|
+
/** The discriminator values a member of `Options` can declare. An omittable discriminator contributes `undefined`, matching what `propValues` claims for it. */
|
|
2659
|
+
export type $DiscriminatorValue<Options extends readonly SomeType[], Disc extends string> = {
|
|
2660
|
+
[I in keyof Options]: Options[I] extends { _zod: { output: infer Out } }
|
|
2661
|
+
? Disc extends keyof Out
|
|
2662
|
+
? Out[Disc]
|
|
2663
|
+
: never
|
|
2664
|
+
: never;
|
|
2665
|
+
}[number];
|
|
2666
|
+
|
|
2667
|
+
/** The member of `Options` that declares `V`. */
|
|
2668
|
+
export type $DiscriminatedOption<Options extends readonly SomeType[], Disc extends string, V> = {
|
|
2669
|
+
[I in keyof Options]: Options[I] extends { _zod: { output: infer Out } }
|
|
2670
|
+
? Disc extends keyof Out
|
|
2671
|
+
? V extends Out[Disc]
|
|
2672
|
+
? Options[I]
|
|
2673
|
+
: never
|
|
2674
|
+
: never
|
|
2675
|
+
: never;
|
|
2676
|
+
}[number];
|
|
2677
|
+
|
|
2678
|
+
/** Returns the option whose discriminator claims `value`, or throws if ambiguous. */
|
|
2679
|
+
export function getDiscriminatedOption<
|
|
2680
|
+
Options extends readonly SomeType[],
|
|
2681
|
+
Disc extends string,
|
|
2682
|
+
const V extends $DiscriminatorValue<Options, Disc>,
|
|
2683
|
+
>(union: $ZodDiscriminatedUnion<Options, Disc>, value: V): $DiscriminatedOption<Options, Disc, V> {
|
|
2684
|
+
const internals = union._zod;
|
|
2685
|
+
let map = internals.bag.optionsMap;
|
|
2686
|
+
if (!map) {
|
|
2687
|
+
map = discriminatorMap(internals.def);
|
|
2688
|
+
internals.bag.optionsMap = map;
|
|
2689
|
+
}
|
|
2690
|
+
const option = map.get(value as util.Primitive);
|
|
2691
|
+
if (option === null) throw new Error(`Ambiguous discriminator value "${String(value)}"`);
|
|
2692
|
+
return option as any;
|
|
2693
|
+
}
|
|
2694
|
+
|
|
2695
|
+
function discriminatorMap(def: $ZodDiscriminatedUnionDef<readonly SomeType[]>): Map<util.Primitive, $ZodType | null> {
|
|
2696
|
+
const map = new Map<util.Primitive, $ZodType | null>();
|
|
2697
|
+
for (const option of def.options as readonly $ZodType[]) {
|
|
2698
|
+
const values = option._zod.propValues?.[def.discriminator];
|
|
2699
|
+
if (!values || values.size === 0)
|
|
2700
|
+
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
|
|
2701
|
+
for (const value of values) {
|
|
2702
|
+
if (map.has(value)) {
|
|
2703
|
+
if (value !== undefined) throw new Error(`Duplicate discriminator value "${String(value)}"`);
|
|
2704
|
+
// keep the collision marked so a later member cannot reclaim it
|
|
2705
|
+
map.set(value, null);
|
|
2706
|
+
} else {
|
|
2707
|
+
map.set(value, option);
|
|
2708
|
+
}
|
|
2709
|
+
}
|
|
2710
|
+
}
|
|
2711
|
+
return map;
|
|
2264
2712
|
}
|
|
2265
2713
|
|
|
2266
2714
|
export interface $ZodDiscriminatedUnion<
|
|
@@ -2278,39 +2726,37 @@ export const $ZodDiscriminatedUnion: core.$constructor<$ZodDiscriminatedUnion> =
|
|
|
2278
2726
|
$ZodUnion.init(inst, def);
|
|
2279
2727
|
|
|
2280
2728
|
const _super = inst._zod.parse;
|
|
2281
|
-
util.
|
|
2729
|
+
util.defineLazyInternal(inst, "propValues", (zod) => {
|
|
2282
2730
|
const propValues: util.PropValues = {};
|
|
2283
|
-
|
|
2731
|
+
let undefinedCount = 0;
|
|
2732
|
+
for (const option of zod.def.options) {
|
|
2284
2733
|
const pv = option._zod.propValues;
|
|
2285
2734
|
if (!pv || Object.keys(pv).length === 0)
|
|
2286
|
-
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
|
|
2735
|
+
throw new Error(`Invalid discriminated union option at index "${zod.def.options.indexOf(option)}"`);
|
|
2736
|
+
if (pv[zod.def.discriminator]?.has(undefined)) undefinedCount++;
|
|
2287
2737
|
for (const [k, v] of Object.entries(pv!)) {
|
|
2288
|
-
if (!propValues
|
|
2738
|
+
if (!Object.prototype.hasOwnProperty.call(propValues, k)) {
|
|
2739
|
+
util.assignProp(propValues, k, new Set());
|
|
2740
|
+
}
|
|
2289
2741
|
for (const val of v) {
|
|
2290
2742
|
propValues[k].add(val);
|
|
2291
2743
|
}
|
|
2292
2744
|
}
|
|
2293
2745
|
}
|
|
2746
|
+
if (!zod.def.unionFallback && undefinedCount > 1) propValues[zod.def.discriminator]?.delete(undefined);
|
|
2294
2747
|
return propValues;
|
|
2295
2748
|
});
|
|
2296
2749
|
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
const
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
if (!values || values.size === 0)
|
|
2303
|
-
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
|
|
2304
|
-
for (const v of values) {
|
|
2305
|
-
if (map.has(v)) {
|
|
2306
|
-
throw new Error(`Duplicate discriminator value "${String(v)}"`);
|
|
2307
|
-
}
|
|
2308
|
-
map.set(v, o);
|
|
2309
|
-
}
|
|
2750
|
+
// Checked now rather than in the lookup map below, so an option that lacks the discriminator fails at the `discriminatedUnion` call instead of on the first object parsed. Options whose shape cannot be enumerated without resolving it — pipes and lazies — are left to the map.
|
|
2751
|
+
def.options.forEach((option, i) => {
|
|
2752
|
+
const propShape = util.rawShape(option._zod.def);
|
|
2753
|
+
if (propShape && !Object.prototype.hasOwnProperty.call(propShape, def.discriminator)) {
|
|
2754
|
+
throw new Error(`Invalid discriminated union option at index "${i}"`);
|
|
2310
2755
|
}
|
|
2311
|
-
return map;
|
|
2312
2756
|
});
|
|
2313
2757
|
|
|
2758
|
+
const disc = util.cached(() => discriminatorMap(def));
|
|
2759
|
+
|
|
2314
2760
|
inst._zod.parse = (payload, ctx) => {
|
|
2315
2761
|
const input = payload.value;
|
|
2316
2762
|
if (!util.isObject(input)) {
|
|
@@ -2324,22 +2770,27 @@ export const $ZodDiscriminatedUnion: core.$constructor<$ZodDiscriminatedUnion> =
|
|
|
2324
2770
|
return payload;
|
|
2325
2771
|
}
|
|
2326
2772
|
|
|
2327
|
-
const
|
|
2328
|
-
|
|
2773
|
+
const value = input?.[def.discriminator];
|
|
2774
|
+
const opt = disc.value.get(value as util.Primitive);
|
|
2775
|
+
// forward metadata cannot choose an encoder for an absent tag
|
|
2776
|
+
if (opt && (value !== undefined || ctx.direction !== "backward")) {
|
|
2329
2777
|
return opt._zod.run(payload, ctx) as any;
|
|
2330
2778
|
}
|
|
2331
2779
|
|
|
2332
|
-
|
|
2780
|
+
// Fall back to union matching when the fast discriminator path fails:
|
|
2781
|
+
// - explicitly enabled via unionFallback, or
|
|
2782
|
+
// - during backward direction (encode), since codec-based discriminators have different values in forward vs backward directions
|
|
2783
|
+
if (def.unionFallback || ctx.direction === "backward") {
|
|
2333
2784
|
return _super(payload, ctx);
|
|
2334
2785
|
}
|
|
2335
2786
|
|
|
2336
2787
|
// no matching discriminator
|
|
2337
2788
|
payload.issues.push({
|
|
2338
2789
|
code: "invalid_union",
|
|
2339
|
-
|
|
2340
2790
|
errors: [],
|
|
2341
2791
|
note: "No matching discriminator",
|
|
2342
2792
|
discriminator: def.discriminator,
|
|
2793
|
+
options: Array.from(disc.value.keys()).filter((value) => disc.value.get(value) !== null),
|
|
2343
2794
|
input,
|
|
2344
2795
|
path: [def.discriminator],
|
|
2345
2796
|
inst,
|
|
@@ -2401,7 +2852,7 @@ export const $ZodIntersection: core.$constructor<$ZodIntersection> = /*@__PURE__
|
|
|
2401
2852
|
}
|
|
2402
2853
|
);
|
|
2403
2854
|
|
|
2404
|
-
function mergeValues(
|
|
2855
|
+
export function mergeValues(
|
|
2405
2856
|
a: any,
|
|
2406
2857
|
b: any
|
|
2407
2858
|
): { valid: true; data: any } | { valid: false; mergeErrorPath: (string | number)[] } {
|
|
@@ -2419,7 +2870,9 @@ function mergeValues(
|
|
|
2419
2870
|
const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
|
|
2420
2871
|
|
|
2421
2872
|
const newObj: any = { ...a, ...b };
|
|
2873
|
+
if (Object.prototype.hasOwnProperty.call(newObj, "__proto__")) delete newObj.__proto__;
|
|
2422
2874
|
for (const key of sharedKeys) {
|
|
2875
|
+
if (key === "__proto__") continue;
|
|
2423
2876
|
const sharedValue = mergeValues(a[key], b[key]);
|
|
2424
2877
|
if (!sharedValue.valid) {
|
|
2425
2878
|
return {
|
|
@@ -2460,44 +2913,52 @@ function mergeValues(
|
|
|
2460
2913
|
}
|
|
2461
2914
|
|
|
2462
2915
|
function handleIntersectionResults(result: ParsePayload, left: ParsePayload, right: ParsePayload): ParsePayload {
|
|
2463
|
-
// Track which side(s)
|
|
2916
|
+
// Track which side(s) reject each key. A key rejection is reported only when BOTH sides reject it, so a key owned by one branch survives the other's key schema. strictObject reports these as unrecognized_keys; a record with an open key schema reports one invalid_key per key.
|
|
2464
2917
|
const unrecKeys = new Map<string, { l?: true; r?: true }>();
|
|
2465
2918
|
let unrecIssue: errors.$ZodRawIssue | undefined;
|
|
2919
|
+
const keyIssues = new Map<string, errors.$ZodRawIssue>();
|
|
2466
2920
|
|
|
2467
|
-
|
|
2468
|
-
|
|
2921
|
+
const collect = (iss: errors.$ZodRawIssue, side: "l" | "r"): boolean => {
|
|
2922
|
+
let keys: string[];
|
|
2923
|
+
if (iss.code === "unrecognized_keys" && !iss.path?.length) {
|
|
2469
2924
|
unrecIssue ??= iss;
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2925
|
+
keys = iss.keys as string[];
|
|
2926
|
+
} else if (iss.code === "invalid_key" && iss.origin === "record" && iss.path?.length === 1) {
|
|
2927
|
+
const k = String(iss.path[0]);
|
|
2928
|
+
if (!keyIssues.has(k)) keyIssues.set(k, iss);
|
|
2929
|
+
keys = [k];
|
|
2474
2930
|
} else {
|
|
2475
|
-
|
|
2931
|
+
return false;
|
|
2476
2932
|
}
|
|
2933
|
+
for (const k of keys) {
|
|
2934
|
+
if (!unrecKeys.has(k)) unrecKeys.set(k, {});
|
|
2935
|
+
unrecKeys.get(k)![side] = true;
|
|
2936
|
+
}
|
|
2937
|
+
return true;
|
|
2938
|
+
};
|
|
2939
|
+
|
|
2940
|
+
for (const iss of left.issues) {
|
|
2941
|
+
if (!collect(iss, "l")) result.issues.push(iss);
|
|
2477
2942
|
}
|
|
2478
2943
|
|
|
2479
2944
|
for (const iss of right.issues) {
|
|
2480
|
-
if (iss
|
|
2481
|
-
for (const k of iss.keys) {
|
|
2482
|
-
if (!unrecKeys.has(k)) unrecKeys.set(k, {});
|
|
2483
|
-
unrecKeys.get(k)!.r = true;
|
|
2484
|
-
}
|
|
2485
|
-
} else {
|
|
2486
|
-
result.issues.push(iss);
|
|
2487
|
-
}
|
|
2945
|
+
if (!collect(iss, "r")) result.issues.push(iss);
|
|
2488
2946
|
}
|
|
2489
2947
|
|
|
2490
|
-
// Report only keys
|
|
2948
|
+
// Report only keys rejected by BOTH sides
|
|
2491
2949
|
const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
|
|
2492
|
-
if (bothKeys.length
|
|
2493
|
-
|
|
2950
|
+
if (bothKeys.length) {
|
|
2951
|
+
const aggregated = unrecIssue ? bothKeys.filter((k) => (unrecIssue!.keys as string[]).includes(k)) : [];
|
|
2952
|
+
if (aggregated.length) result.issues.push({ ...unrecIssue!, keys: aggregated });
|
|
2953
|
+
for (const k of bothKeys) {
|
|
2954
|
+
if (!aggregated.includes(k) && keyIssues.has(k)) result.issues.push(keyIssues.get(k)!);
|
|
2955
|
+
}
|
|
2494
2956
|
}
|
|
2495
2957
|
|
|
2496
|
-
if (util.aborted(result)) return result;
|
|
2497
|
-
|
|
2498
2958
|
const merged = mergeValues(left.value, right.value);
|
|
2499
2959
|
|
|
2500
2960
|
if (!merged.valid) {
|
|
2961
|
+
if (util.aborted(result)) return result;
|
|
2501
2962
|
throw new Error(`Unmergable intersection. Error path: ` + `${JSON.stringify(merged.mergeErrorPath)}`);
|
|
2502
2963
|
}
|
|
2503
2964
|
|
|
@@ -2533,7 +2994,7 @@ type TupleInputTypeWithOptionals<T extends util.TupleItems> = T extends readonly
|
|
|
2533
2994
|
...infer Prefix extends SomeType[],
|
|
2534
2995
|
infer Tail extends SomeType,
|
|
2535
2996
|
]
|
|
2536
|
-
? Tail["_zod"]["optin"] extends "optional"
|
|
2997
|
+
? Tail["_zod"]["optin"] extends "optional" | "defaulted"
|
|
2537
2998
|
? [...TupleInputTypeWithOptionals<Prefix>, core.input<Tail>?]
|
|
2538
2999
|
: TupleInputTypeNoOptionals<T>
|
|
2539
3000
|
: [];
|
|
@@ -2575,6 +3036,8 @@ export interface $ZodTuple<
|
|
|
2575
3036
|
export const $ZodTuple: core.$constructor<$ZodTuple> = /*@__PURE__*/ core.$constructor("$ZodTuple", (inst, def) => {
|
|
2576
3037
|
$ZodType.init(inst, def);
|
|
2577
3038
|
const items = def.items;
|
|
3039
|
+
const memo = core.globalConfig.memoizer;
|
|
3040
|
+
memo?.attach(inst);
|
|
2578
3041
|
|
|
2579
3042
|
inst._zod.parse = (payload, ctx) => {
|
|
2580
3043
|
const input = payload.value;
|
|
@@ -2588,73 +3051,91 @@ export const $ZodTuple: core.$constructor<$ZodTuple> = /*@__PURE__*/ core.$const
|
|
|
2588
3051
|
return payload;
|
|
2589
3052
|
}
|
|
2590
3053
|
|
|
2591
|
-
payload.value = [];
|
|
3054
|
+
payload.value = memo ? memo.alloc(inst, payload, [] as unknown[], ctx) : [];
|
|
2592
3055
|
const proms: Promise<any>[] = [];
|
|
2593
3056
|
|
|
2594
|
-
const
|
|
2595
|
-
const
|
|
3057
|
+
const optinStart = getTupleOptStart(items, "optin");
|
|
3058
|
+
const optoutStart = getTupleOptStart(items, "optout");
|
|
2596
3059
|
|
|
2597
3060
|
if (!def.rest) {
|
|
2598
|
-
|
|
2599
|
-
const tooSmall = input.length < optStart - 1;
|
|
2600
|
-
if (tooBig || tooSmall) {
|
|
3061
|
+
if (input.length < optinStart) {
|
|
2601
3062
|
payload.issues.push({
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
3063
|
+
code: "too_small",
|
|
3064
|
+
minimum: optinStart,
|
|
3065
|
+
inclusive: true,
|
|
2606
3066
|
input,
|
|
2607
3067
|
inst,
|
|
2608
3068
|
origin: "array" as const,
|
|
2609
3069
|
});
|
|
2610
3070
|
return payload;
|
|
2611
3071
|
}
|
|
3072
|
+
if (input.length > items.length) {
|
|
3073
|
+
payload.issues.push({
|
|
3074
|
+
code: "too_big",
|
|
3075
|
+
maximum: items.length,
|
|
3076
|
+
inclusive: true,
|
|
3077
|
+
input,
|
|
3078
|
+
inst,
|
|
3079
|
+
origin: "array" as const,
|
|
3080
|
+
});
|
|
3081
|
+
}
|
|
2612
3082
|
}
|
|
2613
3083
|
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
proms.push(result.then((result) => handleTupleResult(result, payload, i)));
|
|
3084
|
+
// Run every item in parallel, collecting results into an indexed array. The post-processing in `handleTupleResults` walks them in order so it can decide whether an absent optional-output error can truncate the tail or must be reported to preserve required output.
|
|
3085
|
+
const itemResults: ParsePayload[] = new Array(items.length);
|
|
3086
|
+
// only tracked when there is a rest loop to skip
|
|
3087
|
+
const abortEarly = def.rest ? ctx?.abortEarly : undefined;
|
|
3088
|
+
let itemAborted = false;
|
|
3089
|
+
for (let i = 0; i < items.length; i++) {
|
|
3090
|
+
const r = items[i]._zod.run({ value: input[i], issues: [] }, ctx);
|
|
3091
|
+
if (r instanceof Promise) {
|
|
3092
|
+
proms.push(
|
|
3093
|
+
r.then((rr) => {
|
|
3094
|
+
itemResults[i] = rr;
|
|
3095
|
+
})
|
|
3096
|
+
);
|
|
2628
3097
|
} else {
|
|
2629
|
-
|
|
3098
|
+
itemResults[i] = r;
|
|
3099
|
+
if (abortEarly && !itemAborted && r.issues.length) itemAborted = util.aborted(r);
|
|
2630
3100
|
}
|
|
2631
3101
|
}
|
|
2632
3102
|
|
|
2633
|
-
|
|
3103
|
+
// sound because rest is non-empty exactly when every fixed index is present, the one case handleTupleResults cannot discard an item's issues
|
|
3104
|
+
if (def.rest && !itemAborted) {
|
|
3105
|
+
let i = items.length - 1;
|
|
2634
3106
|
const rest = input.slice(items.length);
|
|
3107
|
+
let seen = payload.issues.length;
|
|
2635
3108
|
for (const el of rest) {
|
|
3109
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
3110
|
+
if (util.aborted(payload, seen)) break;
|
|
3111
|
+
seen = payload.issues.length;
|
|
3112
|
+
}
|
|
2636
3113
|
i++;
|
|
2637
|
-
const result = def.rest._zod.run(
|
|
2638
|
-
{
|
|
2639
|
-
value: el,
|
|
2640
|
-
issues: [],
|
|
2641
|
-
},
|
|
2642
|
-
ctx
|
|
2643
|
-
);
|
|
2644
|
-
|
|
3114
|
+
const result = def.rest._zod.run({ value: el, issues: [] }, ctx);
|
|
2645
3115
|
if (result instanceof Promise) {
|
|
2646
|
-
proms.push(result.then((
|
|
3116
|
+
proms.push(result.then((r) => handleTupleResult(r, payload, i)));
|
|
2647
3117
|
} else {
|
|
2648
3118
|
handleTupleResult(result, payload, i);
|
|
2649
3119
|
}
|
|
2650
3120
|
}
|
|
2651
3121
|
}
|
|
2652
3122
|
|
|
2653
|
-
if (proms.length)
|
|
2654
|
-
|
|
3123
|
+
if (proms.length) {
|
|
3124
|
+
return Promise.all(proms).then(() => handleTupleResults(itemResults, payload, items, input, optoutStart));
|
|
3125
|
+
}
|
|
3126
|
+
return handleTupleResults(itemResults, payload, items, input, optoutStart);
|
|
2655
3127
|
};
|
|
2656
3128
|
});
|
|
2657
3129
|
|
|
3130
|
+
function getTupleOptStart(items: readonly $ZodType[], key: "optin" | "optout") {
|
|
3131
|
+
for (let i = items.length - 1; i >= 0; i--) {
|
|
3132
|
+
// optin is a three-rung ladder so any rung above `undefined` permits an absent slot; optout stays two-valued.
|
|
3133
|
+
const omittable = key === "optin" ? items[i]._zod.optin !== undefined : items[i]._zod.optout === "optional";
|
|
3134
|
+
if (!omittable) return i + 1;
|
|
3135
|
+
}
|
|
3136
|
+
return 0;
|
|
3137
|
+
}
|
|
3138
|
+
|
|
2658
3139
|
function handleTupleResult(result: ParsePayload, final: ParsePayload<any[]>, index: number) {
|
|
2659
3140
|
if (result.issues.length) {
|
|
2660
3141
|
final.issues.push(...util.prefixIssues(index, result.issues));
|
|
@@ -2662,6 +3143,48 @@ function handleTupleResult(result: ParsePayload, final: ParsePayload<any[]>, ind
|
|
|
2662
3143
|
final.value[index] = result.value;
|
|
2663
3144
|
}
|
|
2664
3145
|
|
|
3146
|
+
function handleTupleResults(
|
|
3147
|
+
itemResults: ParsePayload[],
|
|
3148
|
+
final: ParsePayload<any[]>,
|
|
3149
|
+
items: readonly $ZodType[],
|
|
3150
|
+
input: unknown[],
|
|
3151
|
+
optoutStart: number
|
|
3152
|
+
) {
|
|
3153
|
+
// Walk results in order. Mirror $ZodObject's swallow-on-absent-optional rule, but only after `optoutStart`: the first index where the output tuple tail can be absent.
|
|
3154
|
+
for (let i = 0; i < items.length; i++) {
|
|
3155
|
+
const r = itemResults[i];
|
|
3156
|
+
const isPresent = i < input.length;
|
|
3157
|
+
// The array analog of `handlePropertyResult`'s absent-key early return: the middle rung permits absence without supplying anything in its place, so the tail truncates here instead of materializing whatever the item made of `undefined`.
|
|
3158
|
+
if (!isPresent && i >= optoutStart && items[i]._zod.optin === "optional") {
|
|
3159
|
+
final.value.length = i;
|
|
3160
|
+
break;
|
|
3161
|
+
}
|
|
3162
|
+
if (r.issues.length) {
|
|
3163
|
+
if (!isPresent && i >= optoutStart) {
|
|
3164
|
+
final.value.length = i;
|
|
3165
|
+
break;
|
|
3166
|
+
}
|
|
3167
|
+
final.issues.push(...util.prefixIssues(i, r.issues));
|
|
3168
|
+
}
|
|
3169
|
+
final.value[i] = r.value;
|
|
3170
|
+
}
|
|
3171
|
+
|
|
3172
|
+
// Drop trailing slots that produced `undefined` for absent input
|
|
3173
|
+
// (the array analog of an absent optional key on an object). The
|
|
3174
|
+
// `i >= input.length` floor is critical: an explicit `undefined`
|
|
3175
|
+
// *inside* the input must be preserved even when the schema is
|
|
3176
|
+
// optional-out (e.g. `z.string().or(z.undefined())` accepting an
|
|
3177
|
+
// explicit undefined value).
|
|
3178
|
+
for (let i = final.value.length - 1; i >= input.length; i--) {
|
|
3179
|
+
if (items[i]._zod.optout === "optional" && final.value[i] === undefined) {
|
|
3180
|
+
final.value.length = i;
|
|
3181
|
+
} else {
|
|
3182
|
+
break;
|
|
3183
|
+
}
|
|
3184
|
+
}
|
|
3185
|
+
return final;
|
|
3186
|
+
}
|
|
3187
|
+
|
|
2665
3188
|
//////////////////////////////////////////
|
|
2666
3189
|
//////////////////////////////////////////
|
|
2667
3190
|
////////// //////////
|
|
@@ -2678,6 +3201,7 @@ export interface $ZodRecordDef<Key extends $ZodRecordKey = $ZodRecordKey, Value
|
|
|
2678
3201
|
valueType: Value;
|
|
2679
3202
|
/** @default "strict" - errors on keys not matching keyType. "loose" passes through non-matching keys unchanged. */
|
|
2680
3203
|
mode?: "strict" | "loose";
|
|
3204
|
+
partial?: boolean;
|
|
2681
3205
|
}
|
|
2682
3206
|
|
|
2683
3207
|
// export type $InferZodRecordOutput<
|
|
@@ -2717,11 +3241,17 @@ export type $InferZodRecordInput<
|
|
|
2717
3241
|
Value extends SomeType = $ZodType,
|
|
2718
3242
|
> = Key extends $partial
|
|
2719
3243
|
? Partial<Record<core.input<Key> & PropertyKey, core.input<Value>>>
|
|
2720
|
-
:
|
|
3244
|
+
: // A value schema that accepts an absent slot makes the key omittable on the way in, exactly as it does in an object shape. The output side keeps every key, since the parser fills each one.
|
|
3245
|
+
[Value] extends [OptionalInSchema]
|
|
3246
|
+
? Partial<Record<core.input<Key> & PropertyKey, core.input<Value>>>
|
|
3247
|
+
: Record<core.input<Key> & PropertyKey, core.input<Value>>;
|
|
2721
3248
|
|
|
2722
3249
|
export interface $ZodRecordInternals<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType>
|
|
2723
|
-
extends $ZodTypeInternals
|
|
3250
|
+
extends $ZodTypeInternals {
|
|
2724
3251
|
def: $ZodRecordDef<Key, Value>;
|
|
3252
|
+
// members rather than base type arguments, which TypeScript 7.1 reports as circular for `z.json()`
|
|
3253
|
+
output: $InferZodRecordOutput<Key, Value>;
|
|
3254
|
+
input: $InferZodRecordInput<Key, Value>;
|
|
2725
3255
|
isst: errors.$ZodIssueInvalidType | errors.$ZodIssueInvalidKey<Record<PropertyKey, unknown>>;
|
|
2726
3256
|
optin?: "optional" | undefined;
|
|
2727
3257
|
optout?: "optional" | undefined;
|
|
@@ -2735,6 +3265,8 @@ export interface $ZodRecord<Key extends $ZodRecordKey = $ZodRecordKey, Value ext
|
|
|
2735
3265
|
|
|
2736
3266
|
export const $ZodRecord: core.$constructor<$ZodRecord> = /*@__PURE__*/ core.$constructor("$ZodRecord", (inst, def) => {
|
|
2737
3267
|
$ZodType.init(inst, def);
|
|
3268
|
+
const memo = core.globalConfig.memoizer;
|
|
3269
|
+
memo?.attach(inst);
|
|
2738
3270
|
|
|
2739
3271
|
inst._zod.parse = (payload, ctx) => {
|
|
2740
3272
|
const input = payload.value;
|
|
@@ -2750,15 +3282,35 @@ export const $ZodRecord: core.$constructor<$ZodRecord> = /*@__PURE__*/ core.$con
|
|
|
2750
3282
|
return payload;
|
|
2751
3283
|
}
|
|
2752
3284
|
|
|
3285
|
+
// no guard in either loop below: a record's invalid_key aborts but an enclosing intersection can reconcile it, so a stopped loop hides keys the sibling does not own and the intersection then rejects nothing
|
|
2753
3286
|
const proms: Promise<any>[] = [];
|
|
2754
3287
|
|
|
2755
3288
|
const values = def.keyType._zod.values;
|
|
2756
|
-
if (values) {
|
|
2757
|
-
payload.value = {};
|
|
3289
|
+
if (values && !def.partial) {
|
|
3290
|
+
payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
|
|
2758
3291
|
const recordKeys = new Set<string | symbol>();
|
|
2759
3292
|
for (const key of values) {
|
|
2760
3293
|
if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
|
|
2761
3294
|
recordKeys.add(typeof key === "number" ? key.toString() : key);
|
|
3295
|
+
// A declared __proto__ is stripped but is not an unrecognized key.
|
|
3296
|
+
if (key === "__proto__") continue;
|
|
3297
|
+
const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
3298
|
+
if (keyResult instanceof Promise) {
|
|
3299
|
+
throw new Error("Async schemas not supported in object keys currently");
|
|
3300
|
+
}
|
|
3301
|
+
if (keyResult.issues.length) {
|
|
3302
|
+
payload.issues.push({
|
|
3303
|
+
code: "invalid_key",
|
|
3304
|
+
origin: "record",
|
|
3305
|
+
issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
|
3306
|
+
input: key,
|
|
3307
|
+
path: [key],
|
|
3308
|
+
inst,
|
|
3309
|
+
});
|
|
3310
|
+
continue;
|
|
3311
|
+
}
|
|
3312
|
+
const outKey = keyResult.value as PropertyKey;
|
|
3313
|
+
if (outKey === "__proto__") continue;
|
|
2762
3314
|
const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
|
|
2763
3315
|
|
|
2764
3316
|
if (result instanceof Promise) {
|
|
@@ -2767,14 +3319,14 @@ export const $ZodRecord: core.$constructor<$ZodRecord> = /*@__PURE__*/ core.$con
|
|
|
2767
3319
|
if (result.issues.length) {
|
|
2768
3320
|
payload.issues.push(...util.prefixIssues(key, result.issues));
|
|
2769
3321
|
}
|
|
2770
|
-
payload.value[
|
|
3322
|
+
payload.value[outKey] = result.value;
|
|
2771
3323
|
})
|
|
2772
3324
|
);
|
|
2773
3325
|
} else {
|
|
2774
3326
|
if (result.issues.length) {
|
|
2775
3327
|
payload.issues.push(...util.prefixIssues(key, result.issues));
|
|
2776
3328
|
}
|
|
2777
|
-
payload.value[
|
|
3329
|
+
payload.value[outKey] = result.value;
|
|
2778
3330
|
}
|
|
2779
3331
|
}
|
|
2780
3332
|
}
|
|
@@ -2782,8 +3334,14 @@ export const $ZodRecord: core.$constructor<$ZodRecord> = /*@__PURE__*/ core.$con
|
|
|
2782
3334
|
let unrecognized!: string[];
|
|
2783
3335
|
for (const key in input) {
|
|
2784
3336
|
if (!recordKeys.has(key)) {
|
|
2785
|
-
|
|
2786
|
-
|
|
3337
|
+
if (def.mode === "loose") {
|
|
3338
|
+
// skip __proto__ so it can't replace the result prototype via the assignment setter on the plain {} we build into
|
|
3339
|
+
if (key === "__proto__") continue;
|
|
3340
|
+
payload.value[key] = input[key];
|
|
3341
|
+
} else {
|
|
3342
|
+
unrecognized = unrecognized ?? [];
|
|
3343
|
+
unrecognized.push(key);
|
|
3344
|
+
}
|
|
2787
3345
|
}
|
|
2788
3346
|
}
|
|
2789
3347
|
if (unrecognized && unrecognized.length > 0) {
|
|
@@ -2793,19 +3351,23 @@ export const $ZodRecord: core.$constructor<$ZodRecord> = /*@__PURE__*/ core.$con
|
|
|
2793
3351
|
input,
|
|
2794
3352
|
inst,
|
|
2795
3353
|
keys: unrecognized,
|
|
3354
|
+
continue: true,
|
|
2796
3355
|
});
|
|
2797
3356
|
}
|
|
2798
3357
|
} else {
|
|
2799
|
-
payload.value = {};
|
|
3358
|
+
payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
|
|
3359
|
+
// An enumerable key schema declares which keys the record owns, so a key outside the set is unrecognized. A non-enumerable one (regex, refine) is a constraint every key must satisfy, so a failing key is invalid. Only the former is reconcilable against the other side of an intersection.
|
|
3360
|
+
let unrecognized!: string[];
|
|
3361
|
+
// Reflect.ownKeys for Symbol-key support; filter non-enumerable to match z.object()
|
|
2800
3362
|
for (const key of Reflect.ownKeys(input)) {
|
|
2801
3363
|
if (key === "__proto__") continue;
|
|
3364
|
+
if (!Object.prototype.propertyIsEnumerable.call(input, key)) continue;
|
|
2802
3365
|
let keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
2803
3366
|
if (keyResult instanceof Promise) {
|
|
2804
3367
|
throw new Error("Async schemas not supported in object keys currently");
|
|
2805
3368
|
}
|
|
2806
3369
|
|
|
2807
|
-
// Numeric string fallback: if key is a numeric string and failed, retry with Number(key)
|
|
2808
|
-
// This handles z.number(), z.literal([1, 2, 3]), and unions containing numeric literals
|
|
3370
|
+
// Numeric string fallback: if key is a numeric string and failed, retry with Number(key). This handles z.number(), z.literal([1, 2, 3]), and unions containing numeric literals
|
|
2809
3371
|
const checkNumericKey = typeof key === "string" && regexes.number.test(key) && keyResult.issues.length;
|
|
2810
3372
|
if (checkNumericKey) {
|
|
2811
3373
|
const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx);
|
|
@@ -2821,6 +3383,9 @@ export const $ZodRecord: core.$constructor<$ZodRecord> = /*@__PURE__*/ core.$con
|
|
|
2821
3383
|
if (def.mode === "loose") {
|
|
2822
3384
|
// Pass through unchanged
|
|
2823
3385
|
payload.value[key] = input[key];
|
|
3386
|
+
} else if (values) {
|
|
3387
|
+
unrecognized = unrecognized ?? [];
|
|
3388
|
+
unrecognized.push(key as string);
|
|
2824
3389
|
} else {
|
|
2825
3390
|
// Default "strict" behavior: error on invalid key
|
|
2826
3391
|
payload.issues.push({
|
|
@@ -2835,6 +3400,10 @@ export const $ZodRecord: core.$constructor<$ZodRecord> = /*@__PURE__*/ core.$con
|
|
|
2835
3400
|
continue;
|
|
2836
3401
|
}
|
|
2837
3402
|
|
|
3403
|
+
// the guard above tests the raw input key, but the key schema can normalize an ordinary key into __proto__; re-check the key we actually write under
|
|
3404
|
+
const outKey = keyResult.value as PropertyKey;
|
|
3405
|
+
if (outKey === "__proto__") continue;
|
|
3406
|
+
|
|
2838
3407
|
const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
|
|
2839
3408
|
|
|
2840
3409
|
if (result instanceof Promise) {
|
|
@@ -2843,16 +3412,27 @@ export const $ZodRecord: core.$constructor<$ZodRecord> = /*@__PURE__*/ core.$con
|
|
|
2843
3412
|
if (result.issues.length) {
|
|
2844
3413
|
payload.issues.push(...util.prefixIssues(key, result.issues));
|
|
2845
3414
|
}
|
|
2846
|
-
payload.value[
|
|
3415
|
+
payload.value[outKey] = result.value;
|
|
2847
3416
|
})
|
|
2848
3417
|
);
|
|
2849
3418
|
} else {
|
|
2850
3419
|
if (result.issues.length) {
|
|
2851
3420
|
payload.issues.push(...util.prefixIssues(key, result.issues));
|
|
2852
3421
|
}
|
|
2853
|
-
payload.value[
|
|
3422
|
+
payload.value[outKey] = result.value;
|
|
2854
3423
|
}
|
|
2855
3424
|
}
|
|
3425
|
+
|
|
3426
|
+
if (unrecognized && unrecognized.length > 0) {
|
|
3427
|
+
payload.issues.push({
|
|
3428
|
+
code: "unrecognized_keys",
|
|
3429
|
+
|
|
3430
|
+
input,
|
|
3431
|
+
inst,
|
|
3432
|
+
keys: unrecognized,
|
|
3433
|
+
continue: true,
|
|
3434
|
+
});
|
|
3435
|
+
}
|
|
2856
3436
|
}
|
|
2857
3437
|
|
|
2858
3438
|
if (proms.length) {
|
|
@@ -2889,6 +3469,8 @@ export interface $ZodMap<Key extends SomeType = $ZodType, Value extends SomeType
|
|
|
2889
3469
|
|
|
2890
3470
|
export const $ZodMap: core.$constructor<$ZodMap> = /*@__PURE__*/ core.$constructor("$ZodMap", (inst, def) => {
|
|
2891
3471
|
$ZodType.init(inst, def);
|
|
3472
|
+
const memo = core.globalConfig.memoizer;
|
|
3473
|
+
memo?.attach(inst);
|
|
2892
3474
|
|
|
2893
3475
|
inst._zod.parse = (payload, ctx) => {
|
|
2894
3476
|
const input = payload.value;
|
|
@@ -2904,9 +3486,15 @@ export const $ZodMap: core.$constructor<$ZodMap> = /*@__PURE__*/ core.$construct
|
|
|
2904
3486
|
}
|
|
2905
3487
|
|
|
2906
3488
|
const proms: Promise<any>[] = [];
|
|
2907
|
-
payload.value = new Map();
|
|
3489
|
+
payload.value = memo ? memo.alloc(inst, payload, new Map(), ctx) : new Map();
|
|
3490
|
+
const abortEarly = ctx?.abortEarly;
|
|
3491
|
+
let seen = payload.issues.length;
|
|
2908
3492
|
|
|
2909
3493
|
for (const [key, value] of input) {
|
|
3494
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
3495
|
+
if (util.aborted(payload, seen)) break;
|
|
3496
|
+
seen = payload.issues.length;
|
|
3497
|
+
}
|
|
2910
3498
|
const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
2911
3499
|
const valueResult = def.valueType._zod.run({ value: value, issues: [] }, ctx);
|
|
2912
3500
|
|
|
@@ -2924,6 +3512,7 @@ export const $ZodMap: core.$constructor<$ZodMap> = /*@__PURE__*/ core.$construct
|
|
|
2924
3512
|
if (proms.length) return Promise.all(proms).then(() => payload);
|
|
2925
3513
|
return payload;
|
|
2926
3514
|
};
|
|
3515
|
+
capSize(inst, mapSize);
|
|
2927
3516
|
});
|
|
2928
3517
|
|
|
2929
3518
|
function handleMapResult(
|
|
@@ -2993,6 +3582,8 @@ export interface $ZodSet<T extends SomeType = $ZodType> extends $ZodType {
|
|
|
2993
3582
|
|
|
2994
3583
|
export const $ZodSet: core.$constructor<$ZodSet> = /*@__PURE__*/ core.$constructor("$ZodSet", (inst, def) => {
|
|
2995
3584
|
$ZodType.init(inst, def);
|
|
3585
|
+
const memo = core.globalConfig.memoizer;
|
|
3586
|
+
memo?.attach(inst);
|
|
2996
3587
|
|
|
2997
3588
|
inst._zod.parse = (payload, ctx) => {
|
|
2998
3589
|
const input = payload.value;
|
|
@@ -3007,8 +3598,14 @@ export const $ZodSet: core.$constructor<$ZodSet> = /*@__PURE__*/ core.$construct
|
|
|
3007
3598
|
}
|
|
3008
3599
|
|
|
3009
3600
|
const proms: Promise<any>[] = [];
|
|
3010
|
-
payload.value = new Set();
|
|
3601
|
+
payload.value = memo ? memo.alloc(inst, payload, new Set(), ctx) : new Set();
|
|
3602
|
+
const abortEarly = ctx?.abortEarly;
|
|
3603
|
+
let seen = payload.issues.length;
|
|
3011
3604
|
for (const item of input) {
|
|
3605
|
+
if (abortEarly && payload.issues.length !== seen) {
|
|
3606
|
+
if (util.aborted(payload, seen)) break;
|
|
3607
|
+
seen = payload.issues.length;
|
|
3608
|
+
}
|
|
3012
3609
|
const result = def.valueType._zod.run({ value: item, issues: [] }, ctx);
|
|
3013
3610
|
if (result instanceof Promise) {
|
|
3014
3611
|
proms.push(result.then((result) => handleSetResult(result, payload)));
|
|
@@ -3018,6 +3615,7 @@ export const $ZodSet: core.$constructor<$ZodSet> = /*@__PURE__*/ core.$construct
|
|
|
3018
3615
|
if (proms.length) return Promise.all(proms).then(() => payload);
|
|
3019
3616
|
return payload;
|
|
3020
3617
|
};
|
|
3618
|
+
capSize(inst, setSize);
|
|
3021
3619
|
});
|
|
3022
3620
|
|
|
3023
3621
|
function handleSetResult(result: ParsePayload, final: ParsePayload<Set<any>>) {
|
|
@@ -3067,12 +3665,13 @@ export const $ZodEnum: core.$constructor<$ZodEnum> = /*@__PURE__*/ core.$constru
|
|
|
3067
3665
|
const valuesSet = new Set<util.Primitive>(values);
|
|
3068
3666
|
inst._zod.values = valuesSet;
|
|
3069
3667
|
|
|
3070
|
-
inst
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
.join("|")})$`
|
|
3075
|
-
|
|
3668
|
+
util.defineLazyInternal(inst, "pattern", (zod) => {
|
|
3669
|
+
const patternValues = util.getEnumValues(zod.def.entries).filter((k) => util.propertyKeyTypes.has(typeof k));
|
|
3670
|
+
// unmatchable fallback, RE2-safe: an empty alternation would compile to /^()$/, which matches ""
|
|
3671
|
+
return new RegExp(
|
|
3672
|
+
patternValues.length ? `^(${patternValues.map((o) => util.escapeRegex(o.toString())).join("|")})$` : "^[^\\s\\S]$"
|
|
3673
|
+
);
|
|
3674
|
+
});
|
|
3076
3675
|
|
|
3077
3676
|
inst._zod.parse = (payload, _ctx) => {
|
|
3078
3677
|
const input = payload.value;
|
|
@@ -3118,18 +3717,23 @@ export const $ZodLiteral: core.$constructor<$ZodLiteral> = /*@__PURE__*/ core.$c
|
|
|
3118
3717
|
"$ZodLiteral",
|
|
3119
3718
|
(inst, def) => {
|
|
3120
3719
|
$ZodType.init(inst, def);
|
|
3121
|
-
if (def.values.length === 0) {
|
|
3122
|
-
throw new Error("Cannot create literal schema with no valid values");
|
|
3123
|
-
}
|
|
3124
3720
|
|
|
3125
3721
|
const values = new Set<util.Literal>(def.values);
|
|
3126
3722
|
inst._zod.values = values;
|
|
3127
|
-
inst._zod.pattern = new RegExp(
|
|
3128
|
-
`^(${def.values
|
|
3129
3723
|
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3724
|
+
util.defineLazyInternal(inst, "pattern", (zod) => {
|
|
3725
|
+
const vals = zod.def.values;
|
|
3726
|
+
// unmatchable fallback, RE2-safe: an empty alternation would compile to /^()$/, which matches ""
|
|
3727
|
+
return new RegExp(
|
|
3728
|
+
vals.length
|
|
3729
|
+
? `^(${vals
|
|
3730
|
+
.map((o: util.Literal) =>
|
|
3731
|
+
typeof o === "string" ? util.escapeRegex(o) : o ? util.escapeRegex(o.toString()) : String(o)
|
|
3732
|
+
)
|
|
3733
|
+
.join("|")})$`
|
|
3734
|
+
: "^[^\\s\\S]$"
|
|
3735
|
+
);
|
|
3736
|
+
});
|
|
3133
3737
|
|
|
3134
3738
|
inst._zod.parse = (payload, _ctx) => {
|
|
3135
3739
|
const input = payload.value;
|
|
@@ -3265,6 +3869,9 @@ export const $ZodTransform: core.$constructor<$ZodTransform> = /*@__PURE__*/ cor
|
|
|
3265
3869
|
"$ZodTransform",
|
|
3266
3870
|
(inst, def) => {
|
|
3267
3871
|
$ZodType.init(inst, def);
|
|
3872
|
+
inst._zod.optin = "optional";
|
|
3873
|
+
core.globalConfig.memoizer?.guard(inst);
|
|
3874
|
+
|
|
3268
3875
|
inst._zod.parse = (payload, ctx) => {
|
|
3269
3876
|
if (ctx.direction === "backward") {
|
|
3270
3877
|
throw new core.$ZodEncodeError(inst.constructor.name);
|
|
@@ -3304,7 +3911,7 @@ export interface $ZodOptionalDef<T extends SomeType = $ZodType> extends $ZodType
|
|
|
3304
3911
|
export interface $ZodOptionalInternals<T extends SomeType = $ZodType>
|
|
3305
3912
|
extends $ZodTypeInternals<core.output<T> | undefined, core.input<T> | undefined> {
|
|
3306
3913
|
def: $ZodOptionalDef<T>;
|
|
3307
|
-
optin: "optional";
|
|
3914
|
+
optin: "optional" | "defaulted";
|
|
3308
3915
|
optout: "optional";
|
|
3309
3916
|
isst: never;
|
|
3310
3917
|
values: T["_zod"]["values"];
|
|
@@ -3315,36 +3922,39 @@ export interface $ZodOptional<T extends SomeType = $ZodType> extends $ZodType {
|
|
|
3315
3922
|
_zod: $ZodOptionalInternals<T>;
|
|
3316
3923
|
}
|
|
3317
3924
|
|
|
3318
|
-
function handleOptionalResult(
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
return result;
|
|
3925
|
+
function handleOptionalResult(payload: ParsePayload, result: ParsePayload) {
|
|
3926
|
+
// A substituting schema that still failed has no usable answer; yield undefined. Its issues are simply dropped: it ran on a payload of its own, so there is no shared array to truncate and nothing of the caller's to lose with it.
|
|
3927
|
+
payload.value = result.issues.length ? undefined : result.value;
|
|
3928
|
+
return payload;
|
|
3323
3929
|
}
|
|
3324
3930
|
|
|
3325
3931
|
export const $ZodOptional: core.$constructor<$ZodOptional> = /*@__PURE__*/ core.$constructor(
|
|
3326
3932
|
"$ZodOptional",
|
|
3327
3933
|
(inst, def) => {
|
|
3328
3934
|
$ZodType.init(inst, def);
|
|
3329
|
-
|
|
3935
|
+
// .optional() propagates absence rather than substituting for it, so a defaulted inner keeps its rung.
|
|
3936
|
+
util.defineLazyInternal(inst, "optin", (zod) =>
|
|
3937
|
+
zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional"
|
|
3938
|
+
);
|
|
3330
3939
|
inst._zod.optout = "optional";
|
|
3331
3940
|
|
|
3332
|
-
util.
|
|
3333
|
-
|
|
3941
|
+
util.defineLazyInternal(inst, "values", (zod) => {
|
|
3942
|
+
const values = (zod.def as $ZodOptionalDef).innerType._zod.values;
|
|
3943
|
+
return values ? new Set([...values, undefined]) : undefined;
|
|
3334
3944
|
});
|
|
3335
|
-
util.
|
|
3336
|
-
const pattern = def.innerType._zod.pattern;
|
|
3945
|
+
util.defineLazyInternal(inst, "pattern", (zod) => {
|
|
3946
|
+
const pattern = (zod.def as $ZodOptionalDef).innerType._zod.pattern;
|
|
3337
3947
|
return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)})?$`) : undefined;
|
|
3338
3948
|
});
|
|
3339
3949
|
|
|
3340
3950
|
inst._zod.parse = (payload, ctx) => {
|
|
3341
|
-
if (def.innerType._zod.optin === "optional") {
|
|
3342
|
-
const result = def.innerType._zod.run(payload, ctx);
|
|
3343
|
-
if (result instanceof Promise) return result.then((r) => handleOptionalResult(r, payload.value));
|
|
3344
|
-
return handleOptionalResult(result, payload.value);
|
|
3345
|
-
}
|
|
3346
3951
|
if (payload.value === undefined) {
|
|
3347
|
-
|
|
3952
|
+
// Only the top rung substitutes a value for absence; everything else leaves it intact, which is what .optional() means.
|
|
3953
|
+
if (def.innerType._zod.optin !== "defaulted") return payload;
|
|
3954
|
+
// Its own payload, for the same reason $ZodCatch gets one: a pipe forwards an unrecognized key through the caller's issues array, and this must not read that as the substituting schema failing and drop it.
|
|
3955
|
+
const result = def.innerType._zod.run({ value: payload.value, issues: [] }, ctx);
|
|
3956
|
+
if (result instanceof Promise) return result.then((result) => handleOptionalResult(payload, result));
|
|
3957
|
+
return handleOptionalResult(payload, result);
|
|
3348
3958
|
}
|
|
3349
3959
|
return def.innerType._zod.run(payload, ctx);
|
|
3350
3960
|
};
|
|
@@ -3380,8 +3990,8 @@ export const $ZodExactOptional: core.$constructor<$ZodExactOptional> = /*@__PURE
|
|
|
3380
3990
|
$ZodOptional.init(inst, def);
|
|
3381
3991
|
|
|
3382
3992
|
// Override values/pattern to NOT add undefined
|
|
3383
|
-
util.
|
|
3384
|
-
util.
|
|
3993
|
+
util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
3994
|
+
util.defineLazyInternal(inst, "pattern", (zod) => zod.def.innerType._zod.pattern);
|
|
3385
3995
|
|
|
3386
3996
|
// Override parse to just delegate (no undefined handling)
|
|
3387
3997
|
inst._zod.parse = (payload, ctx) => {
|
|
@@ -3420,16 +4030,16 @@ export const $ZodNullable: core.$constructor<$ZodNullable> = /*@__PURE__*/ core.
|
|
|
3420
4030
|
"$ZodNullable",
|
|
3421
4031
|
(inst, def) => {
|
|
3422
4032
|
$ZodType.init(inst, def);
|
|
3423
|
-
util.
|
|
3424
|
-
util.
|
|
4033
|
+
util.defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin);
|
|
4034
|
+
util.defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
|
|
3425
4035
|
|
|
3426
|
-
util.
|
|
3427
|
-
const pattern = def.innerType._zod.pattern;
|
|
4036
|
+
util.defineLazyInternal(inst, "pattern", (zod) => {
|
|
4037
|
+
const pattern = zod.def.innerType._zod.pattern;
|
|
3428
4038
|
return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)}|null)$`) : undefined;
|
|
3429
4039
|
});
|
|
3430
4040
|
|
|
3431
|
-
util.
|
|
3432
|
-
return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : undefined;
|
|
4041
|
+
util.defineLazyInternal(inst, "values", (zod) => {
|
|
4042
|
+
return zod.def.innerType._zod.values ? new Set([...zod.def.innerType._zod.values, null]) : undefined;
|
|
3433
4043
|
});
|
|
3434
4044
|
|
|
3435
4045
|
inst._zod.parse = (payload, ctx) => {
|
|
@@ -3458,7 +4068,7 @@ export interface $ZodDefaultDef<T extends SomeType = $ZodType> extends $ZodTypeD
|
|
|
3458
4068
|
export interface $ZodDefaultInternals<T extends SomeType = $ZodType>
|
|
3459
4069
|
extends $ZodTypeInternals<util.NoUndefined<core.output<T>>, core.input<T> | undefined> {
|
|
3460
4070
|
def: $ZodDefaultDef<T>;
|
|
3461
|
-
optin: "
|
|
4071
|
+
optin: "defaulted";
|
|
3462
4072
|
optout?: "optional" | undefined; // required
|
|
3463
4073
|
isst: never;
|
|
3464
4074
|
values: T["_zod"]["values"];
|
|
@@ -3474,8 +4084,8 @@ export const $ZodDefault: core.$constructor<$ZodDefault> = /*@__PURE__*/ core.$c
|
|
|
3474
4084
|
$ZodType.init(inst, def);
|
|
3475
4085
|
|
|
3476
4086
|
// inst._zod.qin = "true";
|
|
3477
|
-
inst._zod.optin = "
|
|
3478
|
-
util.
|
|
4087
|
+
inst._zod.optin = "defaulted";
|
|
4088
|
+
util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
3479
4089
|
|
|
3480
4090
|
inst._zod.parse = (payload, ctx) => {
|
|
3481
4091
|
if (ctx.direction === "backward") {
|
|
@@ -3523,9 +4133,9 @@ export interface $ZodPrefaultDef<T extends SomeType = $ZodType> extends $ZodType
|
|
|
3523
4133
|
}
|
|
3524
4134
|
|
|
3525
4135
|
export interface $ZodPrefaultInternals<T extends SomeType = $ZodType>
|
|
3526
|
-
extends $ZodTypeInternals<
|
|
4136
|
+
extends $ZodTypeInternals<core.output<T>, core.input<T> | undefined> {
|
|
3527
4137
|
def: $ZodPrefaultDef<T>;
|
|
3528
|
-
optin: "
|
|
4138
|
+
optin: "defaulted";
|
|
3529
4139
|
optout?: "optional" | undefined;
|
|
3530
4140
|
isst: never;
|
|
3531
4141
|
values: T["_zod"]["values"];
|
|
@@ -3540,8 +4150,8 @@ export const $ZodPrefault: core.$constructor<$ZodPrefault> = /*@__PURE__*/ core.
|
|
|
3540
4150
|
(inst, def) => {
|
|
3541
4151
|
$ZodType.init(inst, def);
|
|
3542
4152
|
|
|
3543
|
-
inst._zod.optin = "
|
|
3544
|
-
util.
|
|
4153
|
+
inst._zod.optin = "defaulted";
|
|
4154
|
+
util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
3545
4155
|
|
|
3546
4156
|
inst._zod.parse = (payload, ctx) => {
|
|
3547
4157
|
if (ctx.direction === "backward") {
|
|
@@ -3587,8 +4197,8 @@ export const $ZodNonOptional: core.$constructor<$ZodNonOptional> = /*@__PURE__*/
|
|
|
3587
4197
|
(inst, def) => {
|
|
3588
4198
|
$ZodType.init(inst, def);
|
|
3589
4199
|
|
|
3590
|
-
util.
|
|
3591
|
-
const v = def.innerType._zod.values;
|
|
4200
|
+
util.defineLazyInternal(inst, "values", (zod) => {
|
|
4201
|
+
const v = zod.def.innerType._zod.values;
|
|
3592
4202
|
return v ? new Set([...v].filter((x) => x !== undefined)) : undefined;
|
|
3593
4203
|
});
|
|
3594
4204
|
|
|
@@ -3732,11 +4342,33 @@ export interface $ZodCatch<T extends SomeType = $ZodType> extends $ZodType {
|
|
|
3732
4342
|
_zod: $ZodCatchInternals<T>;
|
|
3733
4343
|
}
|
|
3734
4344
|
|
|
4345
|
+
function handleCatchResult(payload: ParsePayload, result: ParsePayload, def: $ZodCatchDef, ctx: ParseContextInternal) {
|
|
4346
|
+
if (!result.issues.length) {
|
|
4347
|
+
payload.value = result.value;
|
|
4348
|
+
// The value carries up, so the flag describing it has to carry with it: a back-edge into a node still being parsed must not be frozen by an enclosing readonly, and its checks belong to the node itself. Guarded so the ordinary case adds no own property.
|
|
4349
|
+
if (result.memo) payload.memo = true;
|
|
4350
|
+
return payload;
|
|
4351
|
+
}
|
|
4352
|
+
|
|
4353
|
+
// Spread the inner's own payload, not ours: `value` has to stay the input the catch was handed, and the inner ran on a payload of its own so its issues are already private to this call.
|
|
4354
|
+
payload.value = def.catchValue({
|
|
4355
|
+
...result,
|
|
4356
|
+
value: payload.value,
|
|
4357
|
+
error: {
|
|
4358
|
+
issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
|
4359
|
+
},
|
|
4360
|
+
input: payload.value,
|
|
4361
|
+
});
|
|
4362
|
+
return payload;
|
|
4363
|
+
}
|
|
4364
|
+
|
|
3735
4365
|
export const $ZodCatch: core.$constructor<$ZodCatch> = /*@__PURE__*/ core.$constructor("$ZodCatch", (inst, def) => {
|
|
3736
4366
|
$ZodType.init(inst, def);
|
|
3737
|
-
util.
|
|
3738
|
-
|
|
3739
|
-
|
|
4367
|
+
util.defineLazyInternal(inst, "optin", (zod) =>
|
|
4368
|
+
zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional"
|
|
4369
|
+
);
|
|
4370
|
+
util.defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
|
|
4371
|
+
util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
3740
4372
|
|
|
3741
4373
|
inst._zod.parse = (payload, ctx) => {
|
|
3742
4374
|
if (ctx.direction === "backward") {
|
|
@@ -3744,39 +4376,12 @@ export const $ZodCatch: core.$constructor<$ZodCatch> = /*@__PURE__*/ core.$const
|
|
|
3744
4376
|
}
|
|
3745
4377
|
|
|
3746
4378
|
// Forward direction (decode): apply catch logic
|
|
3747
|
-
const result = def.innerType._zod.run(payload, ctx);
|
|
4379
|
+
const result = def.innerType._zod.run({ value: payload.value, issues: [] }, ctx);
|
|
3748
4380
|
if (result instanceof Promise) {
|
|
3749
|
-
return result.then((result) =>
|
|
3750
|
-
payload.value = result.value;
|
|
3751
|
-
if (result.issues.length) {
|
|
3752
|
-
payload.value = def.catchValue({
|
|
3753
|
-
...payload,
|
|
3754
|
-
error: {
|
|
3755
|
-
issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
|
3756
|
-
},
|
|
3757
|
-
input: payload.value,
|
|
3758
|
-
});
|
|
3759
|
-
payload.issues = [];
|
|
3760
|
-
}
|
|
3761
|
-
|
|
3762
|
-
return payload;
|
|
3763
|
-
});
|
|
4381
|
+
return result.then((result) => handleCatchResult(payload, result, def, ctx));
|
|
3764
4382
|
}
|
|
3765
4383
|
|
|
3766
|
-
payload
|
|
3767
|
-
if (result.issues.length) {
|
|
3768
|
-
payload.value = def.catchValue({
|
|
3769
|
-
...payload,
|
|
3770
|
-
error: {
|
|
3771
|
-
issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
|
|
3772
|
-
},
|
|
3773
|
-
input: payload.value,
|
|
3774
|
-
});
|
|
3775
|
-
|
|
3776
|
-
payload.issues = [];
|
|
3777
|
-
}
|
|
3778
|
-
|
|
3779
|
-
return payload;
|
|
4384
|
+
return handleCatchResult(payload, result, def, ctx);
|
|
3780
4385
|
};
|
|
3781
4386
|
});
|
|
3782
4387
|
|
|
@@ -3850,10 +4455,10 @@ export interface $ZodPipe<A extends SomeType = $ZodType, B extends SomeType = $Z
|
|
|
3850
4455
|
|
|
3851
4456
|
export const $ZodPipe: core.$constructor<$ZodPipe> = /*@__PURE__*/ core.$constructor("$ZodPipe", (inst, def) => {
|
|
3852
4457
|
$ZodType.init(inst, def);
|
|
3853
|
-
util.
|
|
3854
|
-
util.
|
|
3855
|
-
util.
|
|
3856
|
-
util.
|
|
4458
|
+
util.defineLazyInternal(inst, "values", (zod) => zod.def.in._zod.values);
|
|
4459
|
+
util.defineLazyInternal(inst, "optin", (zod) => zod.def.in._zod.optin);
|
|
4460
|
+
util.defineLazyInternal(inst, "optout", (zod) => zod.def.out._zod.optout);
|
|
4461
|
+
util.defineLazyInternal(inst, "propValues", (zod) => zod.def.in._zod.propValues);
|
|
3857
4462
|
|
|
3858
4463
|
inst._zod.parse = (payload, ctx) => {
|
|
3859
4464
|
if (ctx.direction === "backward") {
|
|
@@ -3873,7 +4478,8 @@ export const $ZodPipe: core.$constructor<$ZodPipe> = /*@__PURE__*/ core.$constru
|
|
|
3873
4478
|
});
|
|
3874
4479
|
|
|
3875
4480
|
function handlePipeResult(left: ParsePayload, next: $ZodType, ctx: ParseContextInternal) {
|
|
3876
|
-
|
|
4481
|
+
// Any issue stops the pipe, so a failing refinement never feeds its transform. An unrecognized key is the exception: it describes the input's extra properties, not the value being piped, and an enclosing intersection may yet reconcile it.
|
|
4482
|
+
if (left.issues.some((iss) => iss.code !== "unrecognized_keys")) {
|
|
3877
4483
|
// prevent further checks
|
|
3878
4484
|
left.aborted = true;
|
|
3879
4485
|
return left;
|
|
@@ -3909,10 +4515,10 @@ export interface $ZodCodec<A extends SomeType = $ZodType, B extends SomeType = $
|
|
|
3909
4515
|
|
|
3910
4516
|
export const $ZodCodec: core.$constructor<$ZodCodec> = /*@__PURE__*/ core.$constructor("$ZodCodec", (inst, def) => {
|
|
3911
4517
|
$ZodType.init(inst, def);
|
|
3912
|
-
util.
|
|
3913
|
-
util.
|
|
3914
|
-
util.
|
|
3915
|
-
util.
|
|
4518
|
+
util.defineLazyInternal(inst, "values", (zod) => zod.def.in._zod.values);
|
|
4519
|
+
util.defineLazyInternal(inst, "optin", (zod) => zod.def.in._zod.optin);
|
|
4520
|
+
util.defineLazyInternal(inst, "optout", (zod) => zod.def.out._zod.optout);
|
|
4521
|
+
util.defineLazyInternal(inst, "propValues", (zod) => zod.def.in._zod.propValues);
|
|
3916
4522
|
|
|
3917
4523
|
inst._zod.parse = (payload, ctx) => {
|
|
3918
4524
|
const direction = ctx.direction || "forward";
|
|
@@ -3966,6 +4572,38 @@ function handleCodecTxResult(left: ParsePayload, value: any, nextSchema: SomeTyp
|
|
|
3966
4572
|
return nextSchema._zod.run({ value, issues: left.issues }, ctx);
|
|
3967
4573
|
}
|
|
3968
4574
|
|
|
4575
|
+
/////////////////////////////////////////////////
|
|
4576
|
+
/////////////////////////////////////////////////
|
|
4577
|
+
////////// //////////
|
|
4578
|
+
////////// $ZodPreprocess //////////
|
|
4579
|
+
////////// //////////
|
|
4580
|
+
/////////////////////////////////////////////////
|
|
4581
|
+
/////////////////////////////////////////////////
|
|
4582
|
+
export interface $ZodPreprocessDef<B extends SomeType = $ZodType, I = unknown>
|
|
4583
|
+
extends $ZodPipeDef<$ZodTransform<unknown, I>, B> {
|
|
4584
|
+
in: $ZodTransform<unknown, I>;
|
|
4585
|
+
out: B;
|
|
4586
|
+
}
|
|
4587
|
+
|
|
4588
|
+
export interface $ZodPreprocessInternals<B extends SomeType = $ZodType, I = unknown>
|
|
4589
|
+
extends $ZodPipeInternals<$ZodTransform<unknown, I>, B> {
|
|
4590
|
+
def: $ZodPreprocessDef<B, I>;
|
|
4591
|
+
optin: B["_zod"]["optin"];
|
|
4592
|
+
optout: B["_zod"]["optout"];
|
|
4593
|
+
}
|
|
4594
|
+
|
|
4595
|
+
export interface $ZodPreprocess<B extends SomeType = $ZodType, I = unknown>
|
|
4596
|
+
extends $ZodPipe<$ZodTransform<unknown, I>, B> {
|
|
4597
|
+
_zod: $ZodPreprocessInternals<B, I>;
|
|
4598
|
+
}
|
|
4599
|
+
|
|
4600
|
+
export const $ZodPreprocess: core.$constructor<$ZodPreprocess> = /*@__PURE__*/ core.$constructor(
|
|
4601
|
+
"$ZodPreprocess",
|
|
4602
|
+
(inst, def) => {
|
|
4603
|
+
$ZodPipe.init(inst, def);
|
|
4604
|
+
}
|
|
4605
|
+
);
|
|
4606
|
+
|
|
3969
4607
|
////////////////////////////////////////////
|
|
3970
4608
|
////////////////////////////////////////////
|
|
3971
4609
|
////////// //////////
|
|
@@ -3997,10 +4635,10 @@ export const $ZodReadonly: core.$constructor<$ZodReadonly> = /*@__PURE__*/ core.
|
|
|
3997
4635
|
"$ZodReadonly",
|
|
3998
4636
|
(inst, def) => {
|
|
3999
4637
|
$ZodType.init(inst, def);
|
|
4000
|
-
util.
|
|
4001
|
-
util.
|
|
4002
|
-
util.
|
|
4003
|
-
util.
|
|
4638
|
+
util.defineLazyInternal(inst, "propValues", (zod) => zod.def.innerType._zod.propValues);
|
|
4639
|
+
util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
|
|
4640
|
+
util.defineLazyInternal(inst, "optin", (zod) => zod.def.innerType?._zod?.optin);
|
|
4641
|
+
util.defineLazyInternal(inst, "optout", (zod) => zod.def.innerType?._zod?.optout);
|
|
4004
4642
|
|
|
4005
4643
|
inst._zod.parse = (payload, ctx) => {
|
|
4006
4644
|
if (ctx.direction === "backward") {
|
|
@@ -4016,7 +4654,8 @@ export const $ZodReadonly: core.$constructor<$ZodReadonly> = /*@__PURE__*/ core.
|
|
|
4016
4654
|
);
|
|
4017
4655
|
|
|
4018
4656
|
function handleReadonlyResult(payload: ParsePayload): ParsePayload {
|
|
4019
|
-
|
|
4657
|
+
// A repeat visit hands back a node that is still being built; freezing it here would make the rest of its keys fail to assign.
|
|
4658
|
+
if (!payload.memo) payload.value = Object.freeze(payload.value);
|
|
4020
4659
|
return payload;
|
|
4021
4660
|
}
|
|
4022
4661
|
|
|
@@ -4093,6 +4732,51 @@ export type $PartsToTemplateLiteral<Parts extends $ZodTemplateLiteralPart[]> = [
|
|
|
4093
4732
|
: never
|
|
4094
4733
|
: never;
|
|
4095
4734
|
|
|
4735
|
+
// a leaf's pattern source with its own checks folded in: the last pattern-carrying check wins, else length bounds narrow the catch-all, else an integer format narrows the number form. the fold lives here instead of on `_zod.pattern` so a bundle without template literals never pays for it
|
|
4736
|
+
function leafPattern(schema: $ZodType): string | undefined {
|
|
4737
|
+
const def = schema._zod.def as { pattern?: RegExp; format?: string; checks?: checks.$ZodCheck[] };
|
|
4738
|
+
let pattern = def.pattern;
|
|
4739
|
+
let isInt = !!def.format?.includes("int");
|
|
4740
|
+
let minimum: number | undefined;
|
|
4741
|
+
let maximum: number | undefined;
|
|
4742
|
+
for (const ch of def.checks ?? []) {
|
|
4743
|
+
const d = ch._zod.def as { pattern?: RegExp; format?: string; minimum?: number; maximum?: number; length?: number };
|
|
4744
|
+
if (d.pattern) pattern = d.pattern;
|
|
4745
|
+
isInt ||= !!d.format?.includes("int");
|
|
4746
|
+
const lo = d.minimum ?? d.length;
|
|
4747
|
+
const hi = d.maximum ?? d.length;
|
|
4748
|
+
if (lo !== undefined && (minimum === undefined || lo > minimum)) minimum = lo;
|
|
4749
|
+
if (hi !== undefined && (maximum === undefined || hi < maximum)) maximum = hi;
|
|
4750
|
+
}
|
|
4751
|
+
if (pattern) return pattern.source;
|
|
4752
|
+
// an empty range matches nothing at runtime, and `{8,5}` is not a legal quantifier
|
|
4753
|
+
if (minimum !== undefined && maximum !== undefined && minimum > maximum) return "(?!)";
|
|
4754
|
+
if (minimum !== undefined || maximum !== undefined) return regexes.string({ minimum, maximum }).source;
|
|
4755
|
+
const own = schema._zod.pattern;
|
|
4756
|
+
return (isInt && own === regexes.number ? regexes.integer : own)?.source;
|
|
4757
|
+
}
|
|
4758
|
+
|
|
4759
|
+
// a part's pattern source. a wrapper's pattern embeds its inner pattern's source verbatim, so the folded form is substituted in place without knowing the wrapper's own composition; a union's options are joined the way the union builds its own pattern
|
|
4760
|
+
function partPattern(schema: $ZodType): string | undefined {
|
|
4761
|
+
const def = schema._zod.def as { innerType?: $ZodType; options?: $ZodType[] };
|
|
4762
|
+
const own = schema._zod.pattern?.source;
|
|
4763
|
+
// lazy resolves its inner on the internals, not the def
|
|
4764
|
+
const inner = def.innerType ?? (schema._zod as { innerType?: $ZodType }).innerType;
|
|
4765
|
+
if (inner) {
|
|
4766
|
+
const before = inner._zod.pattern?.source;
|
|
4767
|
+
const after = partPattern(inner);
|
|
4768
|
+
if (own && before && after && after !== before) {
|
|
4769
|
+
return own.replace(util.cleanRegex(before), () => util.cleanRegex(after));
|
|
4770
|
+
}
|
|
4771
|
+
return own;
|
|
4772
|
+
}
|
|
4773
|
+
if (def.options) {
|
|
4774
|
+
const sources = def.options.map(partPattern);
|
|
4775
|
+
if (sources.every(Boolean)) return `^(${sources.map((s) => util.cleanRegex(s!)).join("|")})$`;
|
|
4776
|
+
}
|
|
4777
|
+
return leafPattern(schema);
|
|
4778
|
+
}
|
|
4779
|
+
|
|
4096
4780
|
export const $ZodTemplateLiteral: core.$constructor<$ZodTemplateLiteral> = /*@__PURE__*/ core.$constructor(
|
|
4097
4781
|
"$ZodTemplateLiteral",
|
|
4098
4782
|
(inst, def) => {
|
|
@@ -4101,18 +4785,11 @@ export const $ZodTemplateLiteral: core.$constructor<$ZodTemplateLiteral> = /*@__
|
|
|
4101
4785
|
for (const part of def.parts) {
|
|
4102
4786
|
if (typeof part === "object" && part !== null) {
|
|
4103
4787
|
// is Zod schema
|
|
4104
|
-
|
|
4105
|
-
|
|
4788
|
+
const source = partPattern(part);
|
|
4789
|
+
if (!source) {
|
|
4106
4790
|
throw new Error(`Invalid template literal part, no pattern found: ${[...(part as any)._zod.traits].shift()}`);
|
|
4107
4791
|
}
|
|
4108
|
-
|
|
4109
|
-
const source = part._zod.pattern instanceof RegExp ? part._zod.pattern.source : part._zod.pattern;
|
|
4110
|
-
|
|
4111
|
-
if (!source) throw new Error(`Invalid template literal part: ${part._zod.traits}`);
|
|
4112
|
-
|
|
4113
|
-
const start = source.startsWith("^") ? 1 : 0;
|
|
4114
|
-
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
|
4115
|
-
regexParts.push(source.slice(start, end));
|
|
4792
|
+
regexParts.push(util.cleanRegex(source));
|
|
4116
4793
|
} else if (part === null || util.primitiveTypes.has(typeof part)) {
|
|
4117
4794
|
regexParts.push(util.escapeRegex(`${part}`));
|
|
4118
4795
|
} else {
|
|
@@ -4232,35 +4909,45 @@ export const $ZodFunction: core.$constructor<$ZodFunction> = /*@__PURE__*/ core.
|
|
|
4232
4909
|
"$ZodFunction",
|
|
4233
4910
|
(inst, def) => {
|
|
4234
4911
|
$ZodType.init(inst, def);
|
|
4235
|
-
|
|
4912
|
+
// Defined, not assigned: the classic prototype exposes `_def` as a getter with no setter.
|
|
4913
|
+
Object.defineProperty(inst, "_def", { value: def });
|
|
4236
4914
|
inst._zod.def = def;
|
|
4237
4915
|
|
|
4238
4916
|
inst.implement = (func) => {
|
|
4239
4917
|
if (typeof func !== "function") {
|
|
4240
4918
|
throw new Error("implement() must be called with a function");
|
|
4241
4919
|
}
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4920
|
+
// Defined inline so the closure stays anonymous: binding it to a `const` first names it, which costs 256 bytes per implemented function.
|
|
4921
|
+
return Object.defineProperty(
|
|
4922
|
+
function (this: any, ...args: never[]) {
|
|
4923
|
+
const parsedArgs = inst._def.input ? parse(inst._def.input, args) : args;
|
|
4924
|
+
const result = Reflect.apply(func, this, parsedArgs as never[]);
|
|
4925
|
+
if (inst._def.output) {
|
|
4926
|
+
return parse(inst._def.output, result);
|
|
4927
|
+
}
|
|
4928
|
+
return result as any;
|
|
4929
|
+
},
|
|
4930
|
+
"_zod",
|
|
4931
|
+
{ value: inst._zod, enumerable: false }
|
|
4932
|
+
) as any;
|
|
4250
4933
|
};
|
|
4251
4934
|
|
|
4252
4935
|
inst.implementAsync = (func) => {
|
|
4253
4936
|
if (typeof func !== "function") {
|
|
4254
4937
|
throw new Error("implementAsync() must be called with a function");
|
|
4255
4938
|
}
|
|
4256
|
-
return
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4939
|
+
return Object.defineProperty(
|
|
4940
|
+
async function (this: any, ...args: never[]) {
|
|
4941
|
+
const parsedArgs = inst._def.input ? await parseAsync(inst._def.input, args) : args;
|
|
4942
|
+
const result = await Reflect.apply(func, this, parsedArgs as never[]);
|
|
4943
|
+
if (inst._def.output) {
|
|
4944
|
+
return await parseAsync(inst._def.output, result);
|
|
4945
|
+
}
|
|
4946
|
+
return result;
|
|
4947
|
+
},
|
|
4948
|
+
"_zod",
|
|
4949
|
+
{ value: inst._zod, enumerable: false }
|
|
4950
|
+
) as any;
|
|
4264
4951
|
};
|
|
4265
4952
|
|
|
4266
4953
|
inst._zod.parse = (payload, _ctx) => {
|
|
@@ -4384,18 +5071,16 @@ export interface $ZodLazy<T extends SomeType = $ZodType> extends $ZodType {
|
|
|
4384
5071
|
export const $ZodLazy: core.$constructor<$ZodLazy> = /*@__PURE__*/ core.$constructor("$ZodLazy", (inst, def) => {
|
|
4385
5072
|
$ZodType.init(inst, def);
|
|
4386
5073
|
|
|
4387
|
-
//
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
util.
|
|
4395
|
-
util.
|
|
4396
|
-
util.
|
|
4397
|
-
util.defineLazy(inst._zod, "optin", () => inst._zod.innerType?._zod?.optin ?? undefined);
|
|
4398
|
-
util.defineLazy(inst._zod, "optout", () => inst._zod.innerType?._zod?.optout ?? undefined);
|
|
5074
|
+
// Cache the resolved inner type on the shared `def` so all clones of this lazy (e.g. via `.describe()`/`.meta()`) share the same inner instance, preserving identity for cycle detection on recursive schemas.
|
|
5075
|
+
util.defineLazy(inst._zod, "innerType", () => {
|
|
5076
|
+
const d = def as $ZodLazyDef & { _cachedInner?: $ZodType };
|
|
5077
|
+
if (!d._cachedInner) d._cachedInner = def.getter() as $ZodType;
|
|
5078
|
+
return d._cachedInner;
|
|
5079
|
+
});
|
|
5080
|
+
util.defineLazyInternal(inst, "pattern", (zod) => zod.innerType?._zod?.pattern);
|
|
5081
|
+
util.defineLazyInternal(inst, "propValues", (zod) => zod.innerType?._zod?.propValues);
|
|
5082
|
+
util.defineLazyInternal(inst, "optin", (zod) => zod.innerType?._zod?.optin ?? undefined);
|
|
5083
|
+
util.defineLazyInternal(inst, "optout", (zod) => zod.innerType?._zod?.optout ?? undefined);
|
|
4399
5084
|
inst._zod.parse = (payload, ctx) => {
|
|
4400
5085
|
const inner = inst._zod.innerType;
|
|
4401
5086
|
return inner._zod.run(payload, ctx);
|
|
@@ -4532,7 +5217,10 @@ export type $ZodStringFormatTypes =
|
|
|
4532
5217
|
| $ZodBase64
|
|
4533
5218
|
| $ZodBase64URL
|
|
4534
5219
|
| $ZodE164
|
|
5220
|
+
| $ZodCreditCard
|
|
5221
|
+
| $ZodIBAN
|
|
4535
5222
|
| $ZodJWT
|
|
4536
5223
|
| $ZodCustomStringFormat<"hex">
|
|
4537
5224
|
| $ZodCustomStringFormat<util.HashFormat>
|
|
4538
|
-
| $ZodCustomStringFormat<"hostname"
|
|
5225
|
+
| $ZodCustomStringFormat<"hostname">
|
|
5226
|
+
| $ZodCustomStringFormat<"currency_code">;
|