@es-joy/jsoe 0.24.2 → 0.25.0
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/.claude/settings.local.json +9 -0
- package/.ncurc.cjs +2 -2
- package/CHANGES.md +51 -0
- package/README.md +23 -13
- package/badges/coverage-badge.svg +1 -1
- package/dist/eslint.config.d.ts +3 -0
- package/dist/eslint.config.d.ts.map +1 -0
- package/dist/formatAndTypeChoices.d.ts +28 -30
- package/dist/formatAndTypeChoices.d.ts.map +1 -1
- package/dist/formats/indexedDBKey.d.ts.map +1 -1
- package/dist/formats/schema.d.ts +46 -3
- package/dist/formats/schema.d.ts.map +1 -1
- package/dist/formats/structuredCloning.d.ts +3 -0
- package/dist/formats/structuredCloning.d.ts.map +1 -1
- package/dist/formats.d.ts +24 -6
- package/dist/formats.d.ts.map +1 -1
- package/dist/fundamentalTypes/BooleanObjectType.d.ts.map +1 -1
- package/dist/fundamentalTypes/NumberObjectType.d.ts.map +1 -1
- package/dist/fundamentalTypes/StringObjectType.d.ts.map +1 -1
- package/dist/fundamentalTypes/arrayReferenceType.d.ts.map +1 -1
- package/dist/fundamentalTypes/arrayType.d.ts +7 -0
- package/dist/fundamentalTypes/arrayType.d.ts.map +1 -1
- package/dist/fundamentalTypes/bigintObjectType.d.ts.map +1 -1
- package/dist/fundamentalTypes/bigintType.d.ts +10 -0
- package/dist/fundamentalTypes/bigintType.d.ts.map +1 -1
- package/dist/fundamentalTypes/blobType.d.ts.map +1 -1
- package/dist/fundamentalTypes/booleanType.d.ts.map +1 -1
- package/dist/fundamentalTypes/catchType.d.ts +2 -2
- package/dist/fundamentalTypes/catchType.d.ts.map +1 -1
- package/dist/fundamentalTypes/dateType.d.ts.map +1 -1
- package/dist/fundamentalTypes/domexceptionType.d.ts.map +1 -1
- package/dist/fundamentalTypes/enumType.d.ts +2 -2
- package/dist/fundamentalTypes/enumType.d.ts.map +1 -1
- package/dist/fundamentalTypes/errorType.d.ts.map +1 -1
- package/dist/fundamentalTypes/fileType.d.ts +6 -0
- package/dist/fundamentalTypes/fileType.d.ts.map +1 -1
- package/dist/fundamentalTypes/functionType.d.ts.map +1 -1
- package/dist/fundamentalTypes/literalType.d.ts +3 -2
- package/dist/fundamentalTypes/literalType.d.ts.map +1 -1
- package/dist/fundamentalTypes/looseRecordType.d.ts +6 -0
- package/dist/fundamentalTypes/looseRecordType.d.ts.map +1 -0
- package/dist/fundamentalTypes/nanType.d.ts.map +1 -1
- package/dist/fundamentalTypes/neverType.d.ts +2 -2
- package/dist/fundamentalTypes/neverType.d.ts.map +1 -1
- package/dist/fundamentalTypes/noneditableType.d.ts.map +1 -1
- package/dist/fundamentalTypes/nullType.d.ts.map +1 -1
- package/dist/fundamentalTypes/numberType.d.ts.map +1 -1
- package/dist/fundamentalTypes/promiseType.d.ts.map +1 -1
- package/dist/fundamentalTypes/regexpType.d.ts.map +1 -1
- package/dist/fundamentalTypes/stringType.d.ts.map +1 -1
- package/dist/fundamentalTypes/symbolType.d.ts.map +1 -1
- package/dist/fundamentalTypes/undefinedType.d.ts.map +1 -1
- package/dist/fundamentalTypes/voidType.d.ts +2 -2
- package/dist/fundamentalTypes/voidType.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/rollup.config.d.ts +30 -0
- package/dist/rollup.config.d.ts.map +1 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/src/formatAndTypeChoices.d.ts +108 -0
- package/dist/src/formatAndTypeChoices.d.ts.map +1 -0
- package/dist/src/formats/arbitraryJS.d.ts +4 -0
- package/dist/src/formats/arbitraryJS.d.ts.map +1 -0
- package/dist/src/formats/indexedDBKey.d.ts +4 -0
- package/dist/src/formats/indexedDBKey.d.ts.map +1 -0
- package/dist/src/formats/json.d.ts +4 -0
- package/dist/src/formats/json.d.ts.map +1 -0
- package/dist/src/formats/schema.d.ts +17 -0
- package/dist/src/formats/schema.d.ts.map +1 -0
- package/dist/src/formats/structuredCloning.d.ts +19 -0
- package/dist/src/formats/structuredCloning.d.ts.map +1 -0
- package/dist/src/formats.d.ts +135 -0
- package/dist/src/formats.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/BooleanObjectType.d.ts +8 -0
- package/dist/src/fundamentalTypes/BooleanObjectType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/NumberObjectType.d.ts +6 -0
- package/dist/src/fundamentalTypes/NumberObjectType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/StringObjectType.d.ts +6 -0
- package/dist/src/fundamentalTypes/StringObjectType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/arrayReferenceType.d.ts +8 -0
- package/dist/src/fundamentalTypes/arrayReferenceType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/arrayType.d.ts +29 -0
- package/dist/src/fundamentalTypes/arrayType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/bigintObjectType.d.ts +6 -0
- package/dist/src/fundamentalTypes/bigintObjectType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/bigintType.d.ts +6 -0
- package/dist/src/fundamentalTypes/bigintType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/blobType.d.ts +11 -0
- package/dist/src/fundamentalTypes/blobType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/booleanType.d.ts +8 -0
- package/dist/src/fundamentalTypes/booleanType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/catchType.d.ts +6 -0
- package/dist/src/fundamentalTypes/catchType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/dateType.d.ts +26 -0
- package/dist/src/fundamentalTypes/dateType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/domexceptionType.d.ts +6 -0
- package/dist/src/fundamentalTypes/domexceptionType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/enumType.d.ts +6 -0
- package/dist/src/fundamentalTypes/enumType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/errorType.d.ts +6 -0
- package/dist/src/fundamentalTypes/errorType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/fileType.d.ts +13 -0
- package/dist/src/fundamentalTypes/fileType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/filelistType.d.ts +6 -0
- package/dist/src/fundamentalTypes/filelistType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/functionType.d.ts +7 -0
- package/dist/src/fundamentalTypes/functionType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/literalType.d.ts +6 -0
- package/dist/src/fundamentalTypes/literalType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/mapType.d.ts +6 -0
- package/dist/src/fundamentalTypes/mapType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/nanType.d.ts +6 -0
- package/dist/src/fundamentalTypes/nanType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/neverType.d.ts +6 -0
- package/dist/src/fundamentalTypes/neverType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/noneditableType.d.ts +6 -0
- package/dist/src/fundamentalTypes/noneditableType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/nullType.d.ts +6 -0
- package/dist/src/fundamentalTypes/nullType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/numberType.d.ts +6 -0
- package/dist/src/fundamentalTypes/numberType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/objectReferenceType.d.ts +8 -0
- package/dist/src/fundamentalTypes/objectReferenceType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/objectType.d.ts +6 -0
- package/dist/src/fundamentalTypes/objectType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/promiseType.d.ts +6 -0
- package/dist/src/fundamentalTypes/promiseType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/recordType.d.ts +6 -0
- package/dist/src/fundamentalTypes/recordType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/regexpType.d.ts +8 -0
- package/dist/src/fundamentalTypes/regexpType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/setType.d.ts +6 -0
- package/dist/src/fundamentalTypes/setType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/sparseUndefinedType.d.ts +6 -0
- package/dist/src/fundamentalTypes/sparseUndefinedType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/stringType.d.ts +6 -0
- package/dist/src/fundamentalTypes/stringType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/symbolType.d.ts +8 -0
- package/dist/src/fundamentalTypes/symbolType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/tupleType.d.ts +6 -0
- package/dist/src/fundamentalTypes/tupleType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/undefinedType.d.ts +6 -0
- package/dist/src/fundamentalTypes/undefinedType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/voidType.d.ts +6 -0
- package/dist/src/fundamentalTypes/voidType.d.ts.map +1 -0
- package/dist/src/index.d.ts +12 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/subTypes/blobHTMLType.d.ts +20 -0
- package/dist/src/subTypes/blobHTMLType.d.ts.map +1 -0
- package/dist/src/subTypes/falseType.d.ts +8 -0
- package/dist/src/subTypes/falseType.d.ts.map +1 -0
- package/dist/src/subTypes/trueType.d.ts +8 -0
- package/dist/src/subTypes/trueType.d.ts.map +1 -0
- package/dist/src/superTypes/SpecialNumberType.d.ts +6 -0
- package/dist/src/superTypes/SpecialNumberType.d.ts.map +1 -0
- package/dist/src/superTypes/SpecialRealNumberType.d.ts +6 -0
- package/dist/src/superTypes/SpecialRealNumberType.d.ts.map +1 -0
- package/dist/src/superTypes/buffersourceType.d.ts +8 -0
- package/dist/src/superTypes/buffersourceType.d.ts.map +1 -0
- package/dist/src/superTypes/dommatrixType.d.ts +6 -0
- package/dist/src/superTypes/dommatrixType.d.ts.map +1 -0
- package/dist/src/superTypes/dompointType.d.ts +6 -0
- package/dist/src/superTypes/dompointType.d.ts.map +1 -0
- package/dist/src/superTypes/domrectType.d.ts +6 -0
- package/dist/src/superTypes/domrectType.d.ts.map +1 -0
- package/dist/src/superTypes/errorsSpecialType.d.ts +8 -0
- package/dist/src/superTypes/errorsSpecialType.d.ts.map +1 -0
- package/dist/src/typeChoices.d.ts +140 -0
- package/dist/src/typeChoices.d.ts.map +1 -0
- package/dist/src/types.d.ts +758 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/utils/FileList.d.ts +26 -0
- package/dist/src/utils/FileList.d.ts.map +1 -0
- package/dist/src/utils/dialogs.d.ts +111 -0
- package/dist/src/utils/dialogs.d.ts.map +1 -0
- package/dist/src/utils/jsonPointer.d.ts +46 -0
- package/dist/src/utils/jsonPointer.d.ts.map +1 -0
- package/dist/src/utils/media.d.ts +18 -0
- package/dist/src/utils/media.d.ts.map +1 -0
- package/dist/src/utils/objects.d.ts +16 -0
- package/dist/src/utils/objects.d.ts.map +1 -0
- package/dist/src/utils/templateUtils.d.ts +59 -0
- package/dist/src/utils/templateUtils.d.ts.map +1 -0
- package/dist/src/utils/types.d.ts +2 -0
- package/dist/src/utils/types.d.ts.map +1 -0
- package/dist/src/vendor-imports.d.ts +4 -0
- package/dist/src/vendor-imports.d.ts.map +1 -0
- package/dist/subTypes/blobHTMLType.d.ts.map +1 -1
- package/dist/superTypes/SpecialRealNumberType.d.ts.map +1 -1
- package/dist/superTypes/buffersourceType.d.ts.map +1 -1
- package/dist/superTypes/dommatrixType.d.ts.map +1 -1
- package/dist/superTypes/dompointType.d.ts.map +1 -1
- package/dist/superTypes/domrectType.d.ts.map +1 -1
- package/dist/superTypes/errorsSpecialType.d.ts.map +1 -1
- package/dist/typeChoices.d.ts +21 -87
- package/dist/typeChoices.d.ts.map +1 -1
- package/dist/types.d.ts +90 -64
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/FileList.d.ts +4 -3
- package/dist/utils/FileList.d.ts.map +1 -1
- package/dist/utils/dialogs.d.ts +4 -4
- package/dist/utils/dialogs.d.ts.map +1 -1
- package/dist/utils/media.d.ts.map +1 -1
- package/dist/utils/schemaMeta.d.ts +92 -0
- package/dist/utils/schemaMeta.d.ts.map +1 -0
- package/dist/utils/templateUtils.d.ts +3 -3
- package/dist/utils/templateUtils.d.ts.map +1 -1
- package/dist/utils/timing.d.ts +2 -0
- package/dist/utils/timing.d.ts.map +1 -0
- package/dist/utils/types.d.ts +1 -0
- package/dist/utils/types.d.ts.map +1 -1
- package/dist/vendor-imports.d.ts +3 -1
- package/docs/proposals/schema-meta.md +233 -0
- package/eslint.config.js +51 -4
- package/licenseInfo.json +1 -1
- package/package.json +52 -42
- package/pnpm-workspace.yaml +57 -0
- package/rollup.config.js +20 -18
- package/server.js +3 -3
- package/src/deepEqual.js +77 -66
- package/src/deepEqual.js.map +1 -1
- package/src/formatAndTypeChoices.js +62 -58
- package/src/formats/indexedDBKey.js +3 -4
- package/src/formats/schema.js +824 -475
- package/src/formats/structuredCloning.js +189 -80
- package/src/formats.js +17 -5
- package/src/fundamentalTypes/BooleanObjectType.js +4 -5
- package/src/fundamentalTypes/NumberObjectType.js +4 -4
- package/src/fundamentalTypes/StringObjectType.js +3 -4
- package/src/fundamentalTypes/arrayReferenceType.js +0 -2
- package/src/fundamentalTypes/arrayType.js +624 -389
- package/src/fundamentalTypes/bigintObjectType.js +3 -2
- package/src/fundamentalTypes/bigintType.js +79 -17
- package/src/fundamentalTypes/blobType.js +35 -35
- package/src/fundamentalTypes/booleanType.js +16 -8
- package/src/fundamentalTypes/dateType.js +6 -8
- package/src/fundamentalTypes/domexceptionType.js +5 -4
- package/src/fundamentalTypes/errorType.js +39 -32
- package/src/fundamentalTypes/fileType.js +238 -52
- package/src/fundamentalTypes/functionType.js +61 -41
- package/src/fundamentalTypes/nanType.js +5 -4
- package/src/fundamentalTypes/noneditableType.js +4 -3
- package/src/fundamentalTypes/nullType.js +3 -2
- package/src/fundamentalTypes/numberType.js +72 -20
- package/src/fundamentalTypes/promiseType.js +16 -40
- package/src/fundamentalTypes/regexpType.js +7 -13
- package/src/fundamentalTypes/stringType.js +176 -110
- package/src/fundamentalTypes/symbolType.js +3 -2
- package/src/fundamentalTypes/undefinedType.js +3 -2
- package/src/index.js +6 -5
- package/src/jsoe.css +107 -8
- package/src/subTypes/blobHTMLType.js +23 -10
- package/src/superTypes/SpecialNumberType.js +6 -6
- package/src/superTypes/SpecialRealNumberType.js +10 -9
- package/src/superTypes/buffersourceType.js +86 -75
- package/src/superTypes/dommatrixType.js +6 -5
- package/src/superTypes/dompointType.js +6 -5
- package/src/superTypes/domrectType.js +6 -5
- package/src/superTypes/errorsSpecialType.js +54 -35
- package/src/typeChoices.js +373 -53
- package/src/types.js +157 -97
- package/src/utils/FileList.js +3 -3
- package/src/utils/dialogs.js +5 -7
- package/src/utils/jsonPointer.js +1 -1
- package/src/utils/media.js +1 -0
- package/src/utils/schemaMeta.js +257 -0
- package/src/utils/templateUtils.js +3 -3
- package/src/utils/timing.js +12 -0
- package/src/utils/types.js +19 -0
- package/src/vendor-imports.js +10 -2
- package/tsconfig.json +2 -0
- package/vendor/acorn/dist/acorn.d.mts +46 -5
- package/vendor/acorn/dist/acorn.d.ts +46 -5
- package/vendor/acorn/dist/acorn.js +394 -117
- package/vendor/acorn/dist/acorn.mjs +394 -117
- package/vendor/acorn/dist/bin.js +1 -1
- package/vendor/jamilih/dist/{jml-es.js → jml.mjs} +590 -312
- package/vendor/jamilih/package.json +1 -1
- package/vendor/mime/dist/types/other.js +719 -0
- package/vendor/mime/dist/types/standard.js +366 -0
- package/vendor/typeson-registry/dist/index.js +519 -99
- package/vendor/zod/classic/checks.d.ts +1 -0
- package/vendor/zod/classic/checks.js +1 -0
- package/vendor/zod/classic/coerce.d.ts +17 -0
- package/vendor/zod/classic/coerce.js +17 -0
- package/vendor/zod/classic/compat.d.ts +48 -0
- package/vendor/zod/classic/compat.js +31 -0
- package/vendor/zod/classic/deep-partial.d.ts +14 -0
- package/vendor/zod/classic/deep-partial.js +13 -0
- package/vendor/zod/classic/errors.d.ts +29 -0
- package/vendor/zod/classic/errors.js +57 -0
- package/vendor/zod/classic/external.d.ts +19 -0
- package/vendor/zod/classic/external.js +17 -0
- package/vendor/zod/classic/from-json-schema.d.ts +12 -0
- package/vendor/zod/classic/from-json-schema.js +660 -0
- package/vendor/zod/classic/in-out.d.ts +8 -0
- package/vendor/zod/classic/in-out.js +36 -0
- package/vendor/zod/classic/index.d.ts +3 -0
- package/vendor/zod/classic/index.js +4 -0
- package/vendor/zod/classic/iso.d.ts +7 -0
- package/vendor/zod/classic/iso.js +15 -0
- package/vendor/zod/classic/package.json +7 -0
- package/vendor/zod/classic/parse.d.ts +44 -0
- package/vendor/zod/classic/parse.js +16 -0
- package/vendor/zod/classic/schemas.d.ts +802 -0
- package/vendor/zod/classic/schemas.js +1491 -0
- package/vendor/zod/core/api.d.ts +329 -0
- package/vendor/zod/core/api.js +1104 -0
- package/vendor/zod/core/checks.d.ts +278 -0
- package/vendor/zod/core/checks.js +581 -0
- package/vendor/zod/core/compile.d.ts +51 -0
- package/vendor/zod/core/compile.js +1783 -0
- package/vendor/zod/core/core.d.ts +82 -0
- package/vendor/zod/core/core.js +141 -0
- package/vendor/zod/core/doc.d.ts +16 -0
- package/vendor/zod/core/doc.js +33 -0
- package/vendor/zod/core/errors.d.ts +225 -0
- package/vendor/zod/core/errors.js +270 -0
- package/vendor/zod/core/index.d.ts +19 -0
- package/vendor/zod/core/index.js +19 -0
- package/vendor/zod/core/json-schema-generator.d.ts +65 -0
- package/vendor/zod/core/json-schema-generator.js +99 -0
- package/vendor/zod/core/json-schema-processors.d.ts +49 -0
- package/vendor/zod/core/json-schema-processors.js +747 -0
- package/vendor/zod/core/json-schema.d.ts +89 -0
- package/vendor/zod/core/memoizer.d.ts +15 -0
- package/vendor/zod/core/memoizer.js +265 -0
- package/vendor/zod/core/package.json +7 -0
- package/vendor/zod/core/parse.d.ts +52 -0
- package/vendor/zod/core/parse.js +154 -0
- package/vendor/zod/core/regexes.d.ts +87 -0
- package/vendor/zod/core/regexes.js +150 -0
- package/vendor/zod/core/registries.d.ts +35 -0
- package/vendor/zod/core/registries.js +51 -0
- package/vendor/zod/core/schemas.d.ts +1253 -0
- package/vendor/zod/core/schemas.js +2440 -0
- package/vendor/zod/core/standard-schema.d.ts +126 -0
- package/vendor/zod/core/to-json-schema.d.ts +153 -0
- package/vendor/zod/core/to-json-schema.js +650 -0
- package/vendor/zod/core/util.d.ts +257 -0
- package/vendor/zod/core/util.js +846 -0
- package/vendor/zod/core/versions.d.ts +5 -0
- package/vendor/zod/core/versions.js +5 -0
- package/vendor/zod/core/visit.d.ts +30 -0
- package/vendor/zod/core/visit.js +169 -0
- package/vendor/zod/index.d.ts +3 -0
- package/vendor/zod/index.js +4 -0
- package/vendor/zod/locales/ar.d.ts +4 -0
- package/vendor/zod/locales/ar.js +109 -0
- package/vendor/zod/locales/az.d.ts +4 -0
- package/vendor/zod/locales/az.js +108 -0
- package/vendor/zod/locales/be.d.ts +4 -0
- package/vendor/zod/locales/be.js +166 -0
- package/vendor/zod/locales/bg.d.ts +4 -0
- package/vendor/zod/locales/bg.js +123 -0
- package/vendor/zod/locales/bn.d.ts +4 -0
- package/vendor/zod/locales/bn.js +111 -0
- package/vendor/zod/locales/ca.d.ts +4 -0
- package/vendor/zod/locales/ca.js +110 -0
- package/vendor/zod/locales/ckb.d.ts +4 -0
- package/vendor/zod/locales/ckb.js +131 -0
- package/vendor/zod/locales/cs.d.ts +4 -0
- package/vendor/zod/locales/cs.js +114 -0
- package/vendor/zod/locales/da.d.ts +4 -0
- package/vendor/zod/locales/da.js +118 -0
- package/vendor/zod/locales/de.d.ts +4 -0
- package/vendor/zod/locales/de.js +111 -0
- package/vendor/zod/locales/el.d.ts +4 -0
- package/vendor/zod/locales/el.js +110 -0
- package/vendor/zod/locales/en.d.ts +4 -0
- package/vendor/zod/locales/en.js +123 -0
- package/vendor/zod/locales/eo.d.ts +4 -0
- package/vendor/zod/locales/eo.js +112 -0
- package/vendor/zod/locales/es.d.ts +4 -0
- package/vendor/zod/locales/es.js +134 -0
- package/vendor/zod/locales/fa.d.ts +4 -0
- package/vendor/zod/locales/fa.js +117 -0
- package/vendor/zod/locales/fi.d.ts +4 -0
- package/vendor/zod/locales/fi.js +115 -0
- package/vendor/zod/locales/fr-CA.d.ts +4 -0
- package/vendor/zod/locales/fr-CA.js +110 -0
- package/vendor/zod/locales/fr.d.ts +4 -0
- package/vendor/zod/locales/fr.js +127 -0
- package/vendor/zod/locales/gu.d.ts +4 -0
- package/vendor/zod/locales/gu.js +111 -0
- package/vendor/zod/locales/he.d.ts +4 -0
- package/vendor/zod/locales/he.js +219 -0
- package/vendor/zod/locales/hi.d.ts +4 -0
- package/vendor/zod/locales/hi.js +109 -0
- package/vendor/zod/locales/hr.d.ts +4 -0
- package/vendor/zod/locales/hr.js +124 -0
- package/vendor/zod/locales/hu.d.ts +4 -0
- package/vendor/zod/locales/hu.js +111 -0
- package/vendor/zod/locales/hy.d.ts +4 -0
- package/vendor/zod/locales/hy.js +156 -0
- package/vendor/zod/locales/id.d.ts +4 -0
- package/vendor/zod/locales/id.js +109 -0
- package/vendor/zod/locales/index.d.ts +62 -0
- package/vendor/zod/locales/index.js +62 -0
- package/vendor/zod/locales/is.d.ts +4 -0
- package/vendor/zod/locales/is.js +112 -0
- package/vendor/zod/locales/it.d.ts +4 -0
- package/vendor/zod/locales/it.js +111 -0
- package/vendor/zod/locales/ja.d.ts +4 -0
- package/vendor/zod/locales/ja.js +110 -0
- package/vendor/zod/locales/ka.d.ts +4 -0
- package/vendor/zod/locales/ka.js +115 -0
- package/vendor/zod/locales/kh.d.ts +5 -0
- package/vendor/zod/locales/kh.js +5 -0
- package/vendor/zod/locales/km.d.ts +4 -0
- package/vendor/zod/locales/km.js +113 -0
- package/vendor/zod/locales/kn.d.ts +4 -0
- package/vendor/zod/locales/kn.js +114 -0
- package/vendor/zod/locales/ko.d.ts +4 -0
- package/vendor/zod/locales/ko.js +114 -0
- package/vendor/zod/locales/lt.d.ts +4 -0
- package/vendor/zod/locales/lt.js +205 -0
- package/vendor/zod/locales/mk.d.ts +4 -0
- package/vendor/zod/locales/mk.js +112 -0
- package/vendor/zod/locales/ms.d.ts +4 -0
- package/vendor/zod/locales/ms.js +110 -0
- package/vendor/zod/locales/ne.d.ts +4 -0
- package/vendor/zod/locales/ne.js +109 -0
- package/vendor/zod/locales/nl.d.ts +4 -0
- package/vendor/zod/locales/nl.js +113 -0
- package/vendor/zod/locales/nn.d.ts +4 -0
- package/vendor/zod/locales/nn.js +111 -0
- package/vendor/zod/locales/no.d.ts +4 -0
- package/vendor/zod/locales/no.js +111 -0
- package/vendor/zod/locales/ota.d.ts +4 -0
- package/vendor/zod/locales/ota.js +112 -0
- package/vendor/zod/locales/package.json +7 -0
- package/vendor/zod/locales/pl.d.ts +4 -0
- package/vendor/zod/locales/pl.js +112 -0
- package/vendor/zod/locales/ps.d.ts +4 -0
- package/vendor/zod/locales/ps.js +117 -0
- package/vendor/zod/locales/pt-BR.d.ts +4 -0
- package/vendor/zod/locales/pt-BR.js +141 -0
- package/vendor/zod/locales/pt.d.ts +4 -0
- package/vendor/zod/locales/pt.js +140 -0
- package/vendor/zod/locales/ro.d.ts +4 -0
- package/vendor/zod/locales/ro.js +120 -0
- package/vendor/zod/locales/ru.d.ts +4 -0
- package/vendor/zod/locales/ru.js +166 -0
- package/vendor/zod/locales/sk.d.ts +4 -0
- package/vendor/zod/locales/sk.js +114 -0
- package/vendor/zod/locales/sl.d.ts +4 -0
- package/vendor/zod/locales/sl.js +112 -0
- package/vendor/zod/locales/sv.d.ts +4 -0
- package/vendor/zod/locales/sv.js +113 -0
- package/vendor/zod/locales/ta.d.ts +4 -0
- package/vendor/zod/locales/ta.js +113 -0
- package/vendor/zod/locales/th.d.ts +4 -0
- package/vendor/zod/locales/th.js +113 -0
- package/vendor/zod/locales/tk.d.ts +4 -0
- package/vendor/zod/locales/tk.js +105 -0
- package/vendor/zod/locales/tr.d.ts +4 -0
- package/vendor/zod/locales/tr.js +108 -0
- package/vendor/zod/locales/ua.d.ts +5 -0
- package/vendor/zod/locales/ua.js +5 -0
- package/vendor/zod/locales/uk.d.ts +4 -0
- package/vendor/zod/locales/uk.js +111 -0
- package/vendor/zod/locales/ur.d.ts +4 -0
- package/vendor/zod/locales/ur.js +113 -0
- package/vendor/zod/locales/uz.d.ts +4 -0
- package/vendor/zod/locales/uz.js +111 -0
- package/vendor/zod/locales/vi.d.ts +4 -0
- package/vendor/zod/locales/vi.js +111 -0
- package/vendor/zod/locales/yo.d.ts +4 -0
- package/vendor/zod/locales/yo.js +110 -0
- package/vendor/zod/locales/zh-CN.d.ts +4 -0
- package/vendor/zod/locales/zh-CN.js +112 -0
- package/vendor/zod/locales/zh-TW.d.ts +4 -0
- package/vendor/zod/locales/zh-TW.js +110 -0
- package/vendor/zod/mini/checks.d.ts +1 -0
- package/vendor/zod/mini/checks.js +1 -0
- package/vendor/zod/mini/coerce.d.ts +7 -0
- package/vendor/zod/mini/coerce.js +22 -0
- package/vendor/zod/mini/deep-partial.d.ts +14 -0
- package/vendor/zod/mini/deep-partial.js +13 -0
- package/vendor/zod/mini/external.d.ts +16 -0
- package/vendor/zod/mini/external.js +16 -0
- package/vendor/zod/mini/in-out.d.ts +8 -0
- package/vendor/zod/mini/in-out.js +36 -0
- package/vendor/zod/mini/index.d.ts +3 -0
- package/vendor/zod/mini/index.js +3 -0
- package/vendor/zod/mini/iso.d.ts +22 -0
- package/vendor/zod/mini/iso.js +34 -0
- package/vendor/zod/mini/package.json +7 -0
- package/vendor/zod/mini/parse.d.ts +1 -0
- package/vendor/zod/mini/parse.js +1 -0
- package/vendor/zod/mini/schemas.d.ts +475 -0
- package/vendor/zod/mini/schemas.js +987 -0
- package/vendor/zod/package.json +7 -0
- package/vendor/zodexy/dist/esm/index.js +1274 -0
- package/vendor/zodexy/dist/index.js +1088 -0
- package/vendor/zodexy/dist/schema.zodexy.json +1036 -0
- package/dist/fundamentalTypes/nativeEnumType.d.ts +0 -6
- package/dist/fundamentalTypes/nativeEnumType.d.ts.map +0 -1
- package/src/fundamentalTypes/catchType.js +0 -140
- package/src/fundamentalTypes/enumType.js +0 -52
- package/src/fundamentalTypes/literalType.js +0 -81
- package/src/fundamentalTypes/nativeEnumType.js +0 -157
- package/src/fundamentalTypes/neverType.js +0 -49
- package/src/fundamentalTypes/recordType.js +0 -42
- package/src/fundamentalTypes/tupleType.js +0 -39
- package/src/fundamentalTypes/voidType.js +0 -48
- package/vendor/zod/lib/index.mjs +0 -4236
- package/vendor/zodex/dist/esm/dezerialize.d.ts +0 -26
- package/vendor/zodex/dist/esm/dezerialize.js +0 -393
- package/vendor/zodex/dist/esm/index.d.ts +0 -9
- package/vendor/zodex/dist/esm/index.js +0 -4
- package/vendor/zodex/dist/esm/infer.d.ts +0 -29
- package/vendor/zodex/dist/esm/package.json +0 -1
- package/vendor/zodex/dist/esm/types.d.ts +0 -201
- package/vendor/zodex/dist/esm/types.js +0 -13
- package/vendor/zodex/dist/esm/ui.d.ts +0 -23
- package/vendor/zodex/dist/esm/ui.js +0 -10
- package/vendor/zodex/dist/esm/zerialize.d.ts +0 -50
- package/vendor/zodex/dist/esm/zerialize.js +0 -417
- package/vendor/zodex/dist/esm/zod-types.d.ts +0 -11
- /package/vendor/{zodex/dist/esm/infer.js → zod/core/json-schema.js} +0 -0
- /package/vendor/{zodex/dist/esm/zod-types.js → zod/core/standard-schema.js} +0 -0
|
@@ -0,0 +1,1491 @@
|
|
|
1
|
+
import * as core from "../core/index.js";
|
|
2
|
+
import { util } from "../core/index.js";
|
|
3
|
+
import * as processors from "../core/json-schema-processors.js";
|
|
4
|
+
import { createStandardJSONSchemaMethod, createToJSONSchemaMethod } from "../core/to-json-schema.js";
|
|
5
|
+
import en from "../locales/en.js";
|
|
6
|
+
import * as checks from "./checks.js";
|
|
7
|
+
import * as parse from "./parse.js";
|
|
8
|
+
// Register English as the default locale on first ZodType construction. Hooked into the `ZodType` `$constructor` (rather than a top-level `config(en())` in `external.ts`) so bundlers honoring `sideEffects: false` can't tree-shake it out — see #5953, #5725. An explicit `z.config(z.locales.xx())` call wins regardless of order, since this only sets the default when none is present.
|
|
9
|
+
function _ensureDefaultLocale() {
|
|
10
|
+
if (!core.globalConfig.localeError)
|
|
11
|
+
core.config(en());
|
|
12
|
+
}
|
|
13
|
+
// the default memoizer is read by the core container init, which runs before `ZodType.init`, so each container calls this first
|
|
14
|
+
function _ensureDefaultMemoizer() {
|
|
15
|
+
if (!core.globalConfig.memoizer)
|
|
16
|
+
core.config({ memoizer: core.memoizer() });
|
|
17
|
+
}
|
|
18
|
+
export const ZodType = /*@__PURE__*/ core.$constructor("ZodType", (inst, def) => {
|
|
19
|
+
_ensureDefaultLocale();
|
|
20
|
+
core.$ZodType.init(inst, def);
|
|
21
|
+
inst.def = def;
|
|
22
|
+
inst.type = def.type;
|
|
23
|
+
return inst;
|
|
24
|
+
}, {
|
|
25
|
+
check(...chks) {
|
|
26
|
+
const def = this.def;
|
|
27
|
+
return this.clone(util.mergeDefs(def, {
|
|
28
|
+
checks: [
|
|
29
|
+
...(def.checks ?? []),
|
|
30
|
+
...chks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch),
|
|
31
|
+
],
|
|
32
|
+
}), { parent: true });
|
|
33
|
+
},
|
|
34
|
+
with(...chks) {
|
|
35
|
+
return this.check(...chks);
|
|
36
|
+
},
|
|
37
|
+
clone(def, params) {
|
|
38
|
+
return core.clone(this, def, params);
|
|
39
|
+
},
|
|
40
|
+
brand() {
|
|
41
|
+
return this;
|
|
42
|
+
},
|
|
43
|
+
register(reg, meta) {
|
|
44
|
+
reg.add(this, meta);
|
|
45
|
+
return this;
|
|
46
|
+
},
|
|
47
|
+
refine(check, params) {
|
|
48
|
+
return this.check(refine(check, params));
|
|
49
|
+
},
|
|
50
|
+
superRefine(refinement, params) {
|
|
51
|
+
return this.check(superRefine(refinement, params));
|
|
52
|
+
},
|
|
53
|
+
overwrite(fn) {
|
|
54
|
+
return this.check(checks.overwrite(fn));
|
|
55
|
+
},
|
|
56
|
+
optional() {
|
|
57
|
+
return optional(this);
|
|
58
|
+
},
|
|
59
|
+
exactOptional() {
|
|
60
|
+
return exactOptional(this);
|
|
61
|
+
},
|
|
62
|
+
nullable() {
|
|
63
|
+
return nullable(this);
|
|
64
|
+
},
|
|
65
|
+
nullish() {
|
|
66
|
+
return optional(nullable(this));
|
|
67
|
+
},
|
|
68
|
+
nonoptional(params) {
|
|
69
|
+
return nonoptional(this, params);
|
|
70
|
+
},
|
|
71
|
+
array() {
|
|
72
|
+
return array(this);
|
|
73
|
+
},
|
|
74
|
+
or(arg) {
|
|
75
|
+
return union([this, arg]);
|
|
76
|
+
},
|
|
77
|
+
and(arg) {
|
|
78
|
+
return intersection(this, arg);
|
|
79
|
+
},
|
|
80
|
+
transform(tx) {
|
|
81
|
+
return pipe(this, transform(tx));
|
|
82
|
+
},
|
|
83
|
+
default(d) {
|
|
84
|
+
return _default(this, d);
|
|
85
|
+
},
|
|
86
|
+
prefault(d) {
|
|
87
|
+
return prefault(this, d);
|
|
88
|
+
},
|
|
89
|
+
catch(params) {
|
|
90
|
+
return _catch(this, params);
|
|
91
|
+
},
|
|
92
|
+
pipe(target) {
|
|
93
|
+
return pipe(this, target);
|
|
94
|
+
},
|
|
95
|
+
readonly() {
|
|
96
|
+
return readonly(this);
|
|
97
|
+
},
|
|
98
|
+
describe(description) {
|
|
99
|
+
const cl = this.clone();
|
|
100
|
+
core.globalRegistry.add(cl, { description });
|
|
101
|
+
return cl;
|
|
102
|
+
},
|
|
103
|
+
meta(...args) {
|
|
104
|
+
// overloaded: meta() returns the registered metadata, meta(data) returns a clone with `data` registered. The mapped type picks up the second overload, so we accept variadic any-args and return `any` to satisfy both at runtime.
|
|
105
|
+
if (args.length === 0)
|
|
106
|
+
return core.globalRegistry.get(this);
|
|
107
|
+
const cl = this.clone();
|
|
108
|
+
core.globalRegistry.add(cl, args[0]);
|
|
109
|
+
return cl;
|
|
110
|
+
},
|
|
111
|
+
isOptional() {
|
|
112
|
+
return this.safeParse(undefined).success;
|
|
113
|
+
},
|
|
114
|
+
isNullable() {
|
|
115
|
+
return this.safeParse(null).success;
|
|
116
|
+
},
|
|
117
|
+
apply(fn, ...args) {
|
|
118
|
+
return args.length === 0 ? fn(this) : fn(this, ...args);
|
|
119
|
+
},
|
|
120
|
+
// Overrides core's `~standard` to add `jsonSchema`. Must stay a prototype entry: redefining it per instance demotes instances to dictionary mode.
|
|
121
|
+
get "~standard"() {
|
|
122
|
+
return util.hide(this, "~standard", {
|
|
123
|
+
...core.standardProps(this),
|
|
124
|
+
jsonSchema: {
|
|
125
|
+
input: createStandardJSONSchemaMethod(this, "input"),
|
|
126
|
+
output: createStandardJSONSchemaMethod(this, "output"),
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
},
|
|
130
|
+
set "~standard"(value) {
|
|
131
|
+
util.own(this, "~standard", value);
|
|
132
|
+
},
|
|
133
|
+
parse: function _parse(data, params) {
|
|
134
|
+
return parse.parse(this, data, params, { callee: _parse });
|
|
135
|
+
},
|
|
136
|
+
parseAsync: async function _parseAsync(data, params) {
|
|
137
|
+
return await parse.parseAsync(this, data, params, { callee: _parseAsync });
|
|
138
|
+
},
|
|
139
|
+
safeParse(data, params) {
|
|
140
|
+
return parse.safeParse(this, data, params);
|
|
141
|
+
},
|
|
142
|
+
async safeParseAsync(data, params) {
|
|
143
|
+
return parse.safeParseAsync(this, data, params);
|
|
144
|
+
},
|
|
145
|
+
// `spa` is an alias: same function object as `safeParseAsync`, as before.
|
|
146
|
+
get spa() {
|
|
147
|
+
return this?.safeParseAsync;
|
|
148
|
+
},
|
|
149
|
+
set spa(value) {
|
|
150
|
+
util.own(this, "spa", value);
|
|
151
|
+
},
|
|
152
|
+
encode: function _encode(data, params) {
|
|
153
|
+
return parse.encode(this, data, params, { callee: _encode });
|
|
154
|
+
},
|
|
155
|
+
decode: function _decode(data, params) {
|
|
156
|
+
return parse.decode(this, data, params, { callee: _decode });
|
|
157
|
+
},
|
|
158
|
+
encodeAsync: async function _encodeAsync(data, params) {
|
|
159
|
+
return await parse.encodeAsync(this, data, params, { callee: _encodeAsync });
|
|
160
|
+
},
|
|
161
|
+
decodeAsync: async function _decodeAsync(data, params) {
|
|
162
|
+
return await parse.decodeAsync(this, data, params, { callee: _decodeAsync });
|
|
163
|
+
},
|
|
164
|
+
safeEncode(data, params) {
|
|
165
|
+
return parse.safeEncode(this, data, params);
|
|
166
|
+
},
|
|
167
|
+
safeDecode(data, params) {
|
|
168
|
+
return parse.safeDecode(this, data, params);
|
|
169
|
+
},
|
|
170
|
+
async safeEncodeAsync(data, params) {
|
|
171
|
+
return parse.safeEncodeAsync(this, data, params);
|
|
172
|
+
},
|
|
173
|
+
async safeDecodeAsync(data, params) {
|
|
174
|
+
return parse.safeDecodeAsync(this, data, params);
|
|
175
|
+
},
|
|
176
|
+
toJSONSchema(params) {
|
|
177
|
+
return createToJSONSchemaMethod(this, {})(params);
|
|
178
|
+
},
|
|
179
|
+
// Reads through to the registry on every access, so it must not cache.
|
|
180
|
+
get description() {
|
|
181
|
+
return core.globalRegistry.get(this)?.description;
|
|
182
|
+
},
|
|
183
|
+
// No setter: `schema._def = x` throws, as it did when `_def` was a non-writable own property.
|
|
184
|
+
get _def() {
|
|
185
|
+
return this._zod.def;
|
|
186
|
+
},
|
|
187
|
+
});
|
|
188
|
+
/** @internal */
|
|
189
|
+
export const _ZodString = /*@__PURE__*/ core.$constructor("_ZodString", (inst, def) => {
|
|
190
|
+
core.$ZodString.init(inst, def);
|
|
191
|
+
ZodType.init(inst, def);
|
|
192
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.stringProcessor(inst, ctx, json, params);
|
|
193
|
+
const bag = inst._zod.bag;
|
|
194
|
+
inst.format = bag.format ?? null;
|
|
195
|
+
inst.minLength = bag.minimum ?? null;
|
|
196
|
+
inst.maxLength = bag.maximum ?? null;
|
|
197
|
+
}, {
|
|
198
|
+
regex(...args) {
|
|
199
|
+
return this.check(checks.regex(...args));
|
|
200
|
+
},
|
|
201
|
+
includes(...args) {
|
|
202
|
+
return this.check(checks.includes(...args));
|
|
203
|
+
},
|
|
204
|
+
startsWith(...args) {
|
|
205
|
+
return this.check(checks.startsWith(...args));
|
|
206
|
+
},
|
|
207
|
+
endsWith(...args) {
|
|
208
|
+
return this.check(checks.endsWith(...args));
|
|
209
|
+
},
|
|
210
|
+
min(...args) {
|
|
211
|
+
return this.check(checks.minLength(...args));
|
|
212
|
+
},
|
|
213
|
+
max(...args) {
|
|
214
|
+
return this.check(checks.maxLength(...args));
|
|
215
|
+
},
|
|
216
|
+
length(...args) {
|
|
217
|
+
return this.check(checks.length(...args));
|
|
218
|
+
},
|
|
219
|
+
nonempty(...args) {
|
|
220
|
+
return this.check(checks.minLength(1, ...args));
|
|
221
|
+
},
|
|
222
|
+
lowercase(params) {
|
|
223
|
+
return this.check(checks.lowercase(params));
|
|
224
|
+
},
|
|
225
|
+
uppercase(params) {
|
|
226
|
+
return this.check(checks.uppercase(params));
|
|
227
|
+
},
|
|
228
|
+
trim() {
|
|
229
|
+
return this.check(checks.trim());
|
|
230
|
+
},
|
|
231
|
+
normalize(...args) {
|
|
232
|
+
return this.check(checks.normalize(...args));
|
|
233
|
+
},
|
|
234
|
+
toLowerCase() {
|
|
235
|
+
return this.check(checks.toLowerCase());
|
|
236
|
+
},
|
|
237
|
+
toUpperCase() {
|
|
238
|
+
return this.check(checks.toUpperCase());
|
|
239
|
+
},
|
|
240
|
+
slugify() {
|
|
241
|
+
return this.check(checks.slugify());
|
|
242
|
+
},
|
|
243
|
+
});
|
|
244
|
+
export const ZodString = /*@__PURE__*/ core.$constructor("ZodString", (inst, def) => {
|
|
245
|
+
core.$ZodString.init(inst, def);
|
|
246
|
+
_ZodString.init(inst, def);
|
|
247
|
+
}, {
|
|
248
|
+
email(params) {
|
|
249
|
+
return this.check(core._email(ZodEmail, params));
|
|
250
|
+
},
|
|
251
|
+
url(params) {
|
|
252
|
+
return this.check(core._url(ZodURL, params));
|
|
253
|
+
},
|
|
254
|
+
jwt(params) {
|
|
255
|
+
return this.check(core._jwt(ZodJWT, params));
|
|
256
|
+
},
|
|
257
|
+
emoji(params) {
|
|
258
|
+
return this.check(core._emoji(ZodEmoji, params));
|
|
259
|
+
},
|
|
260
|
+
guid(params) {
|
|
261
|
+
return this.check(core._guid(ZodGUID, params));
|
|
262
|
+
},
|
|
263
|
+
uuid(params) {
|
|
264
|
+
return this.check(core._uuid(ZodUUID, params));
|
|
265
|
+
},
|
|
266
|
+
uuidv4(params) {
|
|
267
|
+
return this.check(core._uuidv4(ZodUUID, params));
|
|
268
|
+
},
|
|
269
|
+
uuidv6(params) {
|
|
270
|
+
return this.check(core._uuidv6(ZodUUID, params));
|
|
271
|
+
},
|
|
272
|
+
uuidv7(params) {
|
|
273
|
+
return this.check(core._uuidv7(ZodUUID, params));
|
|
274
|
+
},
|
|
275
|
+
nanoid(params) {
|
|
276
|
+
return this.check(core._nanoid(ZodNanoID, params));
|
|
277
|
+
},
|
|
278
|
+
cuid(params) {
|
|
279
|
+
return this.check(core._cuid(ZodCUID, params));
|
|
280
|
+
},
|
|
281
|
+
cuid2(params) {
|
|
282
|
+
return this.check(core._cuid2(ZodCUID2, params));
|
|
283
|
+
},
|
|
284
|
+
ulid(params) {
|
|
285
|
+
return this.check(core._ulid(ZodULID, params));
|
|
286
|
+
},
|
|
287
|
+
base64(params) {
|
|
288
|
+
return this.check(core._base64(ZodBase64, params));
|
|
289
|
+
},
|
|
290
|
+
base64url(params) {
|
|
291
|
+
return this.check(core._base64url(ZodBase64URL, params));
|
|
292
|
+
},
|
|
293
|
+
xid(params) {
|
|
294
|
+
return this.check(core._xid(ZodXID, params));
|
|
295
|
+
},
|
|
296
|
+
ksuid(params) {
|
|
297
|
+
return this.check(core._ksuid(ZodKSUID, params));
|
|
298
|
+
},
|
|
299
|
+
ipv4(params) {
|
|
300
|
+
return this.check(core._ipv4(ZodIPv4, params));
|
|
301
|
+
},
|
|
302
|
+
ipv6(params) {
|
|
303
|
+
return this.check(core._ipv6(ZodIPv6, params));
|
|
304
|
+
},
|
|
305
|
+
cidrv4(params) {
|
|
306
|
+
return this.check(core._cidrv4(ZodCIDRv4, params));
|
|
307
|
+
},
|
|
308
|
+
cidrv6(params) {
|
|
309
|
+
return this.check(core._cidrv6(ZodCIDRv6, params));
|
|
310
|
+
},
|
|
311
|
+
e164(params) {
|
|
312
|
+
return this.check(core._e164(ZodE164, params));
|
|
313
|
+
},
|
|
314
|
+
datetime(params) {
|
|
315
|
+
return this.check(core._isoDateTime(ZodISODateTime, params));
|
|
316
|
+
},
|
|
317
|
+
date(params) {
|
|
318
|
+
return this.check(core._isoDate(ZodISODate, params));
|
|
319
|
+
},
|
|
320
|
+
time(params) {
|
|
321
|
+
return this.check(core._isoTime(ZodISOTime, params));
|
|
322
|
+
},
|
|
323
|
+
duration(params) {
|
|
324
|
+
return this.check(core._isoDuration(ZodISODuration, params));
|
|
325
|
+
},
|
|
326
|
+
});
|
|
327
|
+
export function string(params) {
|
|
328
|
+
return core._string(ZodString, params);
|
|
329
|
+
}
|
|
330
|
+
export const ZodStringFormat = /*@__PURE__*/ core.$constructor("ZodStringFormat", (inst, def) => {
|
|
331
|
+
core.$ZodStringFormat.init(inst, def);
|
|
332
|
+
_ZodString.init(inst, def);
|
|
333
|
+
});
|
|
334
|
+
export const ZodISODateTime = /*@__PURE__*/ core.$constructor("ZodISODateTime", (inst, def) => {
|
|
335
|
+
core.$ZodISODateTime.init(inst, def);
|
|
336
|
+
ZodStringFormat.init(inst, def);
|
|
337
|
+
});
|
|
338
|
+
export const ZodISODate = /*@__PURE__*/ core.$constructor("ZodISODate", (inst, def) => {
|
|
339
|
+
core.$ZodISODate.init(inst, def);
|
|
340
|
+
ZodStringFormat.init(inst, def);
|
|
341
|
+
});
|
|
342
|
+
export const ZodISOTime = /*@__PURE__*/ core.$constructor("ZodISOTime", (inst, def) => {
|
|
343
|
+
core.$ZodISOTime.init(inst, def);
|
|
344
|
+
ZodStringFormat.init(inst, def);
|
|
345
|
+
});
|
|
346
|
+
export const ZodISODuration = /*@__PURE__*/ core.$constructor("ZodISODuration", (inst, def) => {
|
|
347
|
+
core.$ZodISODuration.init(inst, def);
|
|
348
|
+
ZodStringFormat.init(inst, def);
|
|
349
|
+
});
|
|
350
|
+
export const ZodEmail = /*@__PURE__*/ core.$constructor("ZodEmail", (inst, def) => {
|
|
351
|
+
// ZodStringFormat.init(inst, def);
|
|
352
|
+
core.$ZodEmail.init(inst, def);
|
|
353
|
+
ZodStringFormat.init(inst, def);
|
|
354
|
+
});
|
|
355
|
+
export function email(params) {
|
|
356
|
+
return core._email(ZodEmail, params);
|
|
357
|
+
}
|
|
358
|
+
export const ZodGUID = /*@__PURE__*/ core.$constructor("ZodGUID", (inst, def) => {
|
|
359
|
+
// ZodStringFormat.init(inst, def);
|
|
360
|
+
core.$ZodGUID.init(inst, def);
|
|
361
|
+
ZodStringFormat.init(inst, def);
|
|
362
|
+
});
|
|
363
|
+
export function guid(params) {
|
|
364
|
+
return core._guid(ZodGUID, params);
|
|
365
|
+
}
|
|
366
|
+
export const ZodUUID = /*@__PURE__*/ core.$constructor("ZodUUID", (inst, def) => {
|
|
367
|
+
// ZodStringFormat.init(inst, def);
|
|
368
|
+
core.$ZodUUID.init(inst, def);
|
|
369
|
+
ZodStringFormat.init(inst, def);
|
|
370
|
+
});
|
|
371
|
+
export function uuid(params) {
|
|
372
|
+
return core._uuid(ZodUUID, params);
|
|
373
|
+
}
|
|
374
|
+
export function uuidv4(params) {
|
|
375
|
+
return core._uuidv4(ZodUUID, params);
|
|
376
|
+
}
|
|
377
|
+
// ZodUUIDv6
|
|
378
|
+
export function uuidv6(params) {
|
|
379
|
+
return core._uuidv6(ZodUUID, params);
|
|
380
|
+
}
|
|
381
|
+
// ZodUUIDv7
|
|
382
|
+
export function uuidv7(params) {
|
|
383
|
+
return core._uuidv7(ZodUUID, params);
|
|
384
|
+
}
|
|
385
|
+
export const ZodURL = /*@__PURE__*/ core.$constructor("ZodURL", (inst, def) => {
|
|
386
|
+
// ZodStringFormat.init(inst, def);
|
|
387
|
+
core.$ZodURL.init(inst, def);
|
|
388
|
+
ZodStringFormat.init(inst, def);
|
|
389
|
+
});
|
|
390
|
+
export function url(params) {
|
|
391
|
+
return core._url(ZodURL, params);
|
|
392
|
+
}
|
|
393
|
+
export function httpUrl(params) {
|
|
394
|
+
return core._url(ZodURL, {
|
|
395
|
+
protocol: core.regexes.httpProtocol,
|
|
396
|
+
hostname: core.regexes.domain,
|
|
397
|
+
...util.normalizeParams(params),
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
export const ZodEmoji = /*@__PURE__*/ core.$constructor("ZodEmoji", (inst, def) => {
|
|
401
|
+
// ZodStringFormat.init(inst, def);
|
|
402
|
+
core.$ZodEmoji.init(inst, def);
|
|
403
|
+
ZodStringFormat.init(inst, def);
|
|
404
|
+
});
|
|
405
|
+
export function emoji(params) {
|
|
406
|
+
return core._emoji(ZodEmoji, params);
|
|
407
|
+
}
|
|
408
|
+
export const ZodNanoID = /*@__PURE__*/ core.$constructor("ZodNanoID", (inst, def) => {
|
|
409
|
+
// ZodStringFormat.init(inst, def);
|
|
410
|
+
core.$ZodNanoID.init(inst, def);
|
|
411
|
+
ZodStringFormat.init(inst, def);
|
|
412
|
+
});
|
|
413
|
+
export function nanoid(params) {
|
|
414
|
+
return core._nanoid(ZodNanoID, params);
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
418
|
+
* (timestamps embedded in the id). Use {@link ZodCUID2} instead.
|
|
419
|
+
* See https://github.com/paralleldrive/cuid.
|
|
420
|
+
*/
|
|
421
|
+
export const ZodCUID = /*@__PURE__*/ core.$constructor("ZodCUID", (inst, def) => {
|
|
422
|
+
// ZodStringFormat.init(inst, def);
|
|
423
|
+
core.$ZodCUID.init(inst, def);
|
|
424
|
+
ZodStringFormat.init(inst, def);
|
|
425
|
+
});
|
|
426
|
+
/**
|
|
427
|
+
* Validates a CUID v1 string.
|
|
428
|
+
*
|
|
429
|
+
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
430
|
+
* (timestamps embedded in the id). Use {@link cuid2 | `z.cuid2()`} instead.
|
|
431
|
+
* See https://github.com/paralleldrive/cuid.
|
|
432
|
+
*/
|
|
433
|
+
export function cuid(params) {
|
|
434
|
+
return core._cuid(ZodCUID, params);
|
|
435
|
+
}
|
|
436
|
+
export const ZodCUID2 = /*@__PURE__*/ core.$constructor("ZodCUID2", (inst, def) => {
|
|
437
|
+
// ZodStringFormat.init(inst, def);
|
|
438
|
+
core.$ZodCUID2.init(inst, def);
|
|
439
|
+
ZodStringFormat.init(inst, def);
|
|
440
|
+
});
|
|
441
|
+
export function cuid2(params) {
|
|
442
|
+
return core._cuid2(ZodCUID2, params);
|
|
443
|
+
}
|
|
444
|
+
export const ZodULID = /*@__PURE__*/ core.$constructor("ZodULID", (inst, def) => {
|
|
445
|
+
// ZodStringFormat.init(inst, def);
|
|
446
|
+
core.$ZodULID.init(inst, def);
|
|
447
|
+
ZodStringFormat.init(inst, def);
|
|
448
|
+
});
|
|
449
|
+
export function ulid(params) {
|
|
450
|
+
return core._ulid(ZodULID, params);
|
|
451
|
+
}
|
|
452
|
+
export const ZodXID = /*@__PURE__*/ core.$constructor("ZodXID", (inst, def) => {
|
|
453
|
+
// ZodStringFormat.init(inst, def);
|
|
454
|
+
core.$ZodXID.init(inst, def);
|
|
455
|
+
ZodStringFormat.init(inst, def);
|
|
456
|
+
});
|
|
457
|
+
export function xid(params) {
|
|
458
|
+
return core._xid(ZodXID, params);
|
|
459
|
+
}
|
|
460
|
+
export const ZodKSUID = /*@__PURE__*/ core.$constructor("ZodKSUID", (inst, def) => {
|
|
461
|
+
// ZodStringFormat.init(inst, def);
|
|
462
|
+
core.$ZodKSUID.init(inst, def);
|
|
463
|
+
ZodStringFormat.init(inst, def);
|
|
464
|
+
});
|
|
465
|
+
export function ksuid(params) {
|
|
466
|
+
return core._ksuid(ZodKSUID, params);
|
|
467
|
+
}
|
|
468
|
+
export const ZodIPv4 = /*@__PURE__*/ core.$constructor("ZodIPv4", (inst, def) => {
|
|
469
|
+
// ZodStringFormat.init(inst, def);
|
|
470
|
+
core.$ZodIPv4.init(inst, def);
|
|
471
|
+
ZodStringFormat.init(inst, def);
|
|
472
|
+
});
|
|
473
|
+
export function ipv4(params) {
|
|
474
|
+
return core._ipv4(ZodIPv4, params);
|
|
475
|
+
}
|
|
476
|
+
export const ZodMAC = /*@__PURE__*/ core.$constructor("ZodMAC", (inst, def) => {
|
|
477
|
+
// ZodStringFormat.init(inst, def);
|
|
478
|
+
core.$ZodMAC.init(inst, def);
|
|
479
|
+
ZodStringFormat.init(inst, def);
|
|
480
|
+
});
|
|
481
|
+
export function mac(params) {
|
|
482
|
+
return core._mac(ZodMAC, params);
|
|
483
|
+
}
|
|
484
|
+
export const ZodIPv6 = /*@__PURE__*/ core.$constructor("ZodIPv6", (inst, def) => {
|
|
485
|
+
// ZodStringFormat.init(inst, def);
|
|
486
|
+
core.$ZodIPv6.init(inst, def);
|
|
487
|
+
ZodStringFormat.init(inst, def);
|
|
488
|
+
});
|
|
489
|
+
export function ipv6(params) {
|
|
490
|
+
return core._ipv6(ZodIPv6, params);
|
|
491
|
+
}
|
|
492
|
+
export const ZodCIDRv4 = /*@__PURE__*/ core.$constructor("ZodCIDRv4", (inst, def) => {
|
|
493
|
+
core.$ZodCIDRv4.init(inst, def);
|
|
494
|
+
ZodStringFormat.init(inst, def);
|
|
495
|
+
});
|
|
496
|
+
export function cidrv4(params) {
|
|
497
|
+
return core._cidrv4(ZodCIDRv4, params);
|
|
498
|
+
}
|
|
499
|
+
export const ZodCIDRv6 = /*@__PURE__*/ core.$constructor("ZodCIDRv6", (inst, def) => {
|
|
500
|
+
core.$ZodCIDRv6.init(inst, def);
|
|
501
|
+
ZodStringFormat.init(inst, def);
|
|
502
|
+
});
|
|
503
|
+
export function cidrv6(params) {
|
|
504
|
+
return core._cidrv6(ZodCIDRv6, params);
|
|
505
|
+
}
|
|
506
|
+
export const ZodBase64 = /*@__PURE__*/ core.$constructor("ZodBase64", (inst, def) => {
|
|
507
|
+
// ZodStringFormat.init(inst, def);
|
|
508
|
+
core.$ZodBase64.init(inst, def);
|
|
509
|
+
ZodStringFormat.init(inst, def);
|
|
510
|
+
});
|
|
511
|
+
export function base64(params) {
|
|
512
|
+
return core._base64(ZodBase64, params);
|
|
513
|
+
}
|
|
514
|
+
export const ZodBase64URL = /*@__PURE__*/ core.$constructor("ZodBase64URL", (inst, def) => {
|
|
515
|
+
// ZodStringFormat.init(inst, def);
|
|
516
|
+
core.$ZodBase64URL.init(inst, def);
|
|
517
|
+
ZodStringFormat.init(inst, def);
|
|
518
|
+
});
|
|
519
|
+
export function base64url(params) {
|
|
520
|
+
return core._base64url(ZodBase64URL, params);
|
|
521
|
+
}
|
|
522
|
+
export const ZodE164 = /*@__PURE__*/ core.$constructor("ZodE164", (inst, def) => {
|
|
523
|
+
// ZodStringFormat.init(inst, def);
|
|
524
|
+
core.$ZodE164.init(inst, def);
|
|
525
|
+
ZodStringFormat.init(inst, def);
|
|
526
|
+
});
|
|
527
|
+
export function e164(params) {
|
|
528
|
+
return core._e164(ZodE164, params);
|
|
529
|
+
}
|
|
530
|
+
export const ZodCreditCard = /*@__PURE__*/ core.$constructor("ZodCreditCard", (inst, def) => {
|
|
531
|
+
core.$ZodCreditCard.init(inst, def);
|
|
532
|
+
ZodStringFormat.init(inst, def);
|
|
533
|
+
});
|
|
534
|
+
export function creditCard(params) {
|
|
535
|
+
return core._creditCard(ZodCreditCard, params);
|
|
536
|
+
}
|
|
537
|
+
export const ZodJWT = /*@__PURE__*/ core.$constructor("ZodJWT", (inst, def) => {
|
|
538
|
+
// ZodStringFormat.init(inst, def);
|
|
539
|
+
core.$ZodJWT.init(inst, def);
|
|
540
|
+
ZodStringFormat.init(inst, def);
|
|
541
|
+
});
|
|
542
|
+
export function jwt(params) {
|
|
543
|
+
return core._jwt(ZodJWT, params);
|
|
544
|
+
}
|
|
545
|
+
export const ZodCustomStringFormat = /*@__PURE__*/ core.$constructor("ZodCustomStringFormat", (inst, def) => {
|
|
546
|
+
// ZodStringFormat.init(inst, def);
|
|
547
|
+
core.$ZodCustomStringFormat.init(inst, def);
|
|
548
|
+
ZodStringFormat.init(inst, def);
|
|
549
|
+
});
|
|
550
|
+
export function stringFormat(format, fnOrRegex, _params = {}) {
|
|
551
|
+
return core._stringFormat(ZodCustomStringFormat, format, fnOrRegex, _params);
|
|
552
|
+
}
|
|
553
|
+
export function hostname(_params) {
|
|
554
|
+
return core._stringFormat(ZodCustomStringFormat, "hostname", core.regexes.hostname, _params);
|
|
555
|
+
}
|
|
556
|
+
export function hex(_params) {
|
|
557
|
+
return core._stringFormat(ZodCustomStringFormat, "hex", core.regexes.hex, _params);
|
|
558
|
+
}
|
|
559
|
+
export function hash(alg, params) {
|
|
560
|
+
const enc = params?.enc ?? "hex";
|
|
561
|
+
const format = `${alg}_${enc}`;
|
|
562
|
+
const regex = core.regexes[format];
|
|
563
|
+
if (!regex)
|
|
564
|
+
throw new Error(`Unrecognized hash format: ${format}`);
|
|
565
|
+
return core._stringFormat(ZodCustomStringFormat, format, regex, params);
|
|
566
|
+
}
|
|
567
|
+
export const ZodNumber = /*@__PURE__*/ core.$constructor("ZodNumber", (inst, def) => {
|
|
568
|
+
core.$ZodNumber.init(inst, def);
|
|
569
|
+
ZodType.init(inst, def);
|
|
570
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.numberProcessor(inst, ctx, json, params);
|
|
571
|
+
const bag = inst._zod.bag;
|
|
572
|
+
inst.minValue =
|
|
573
|
+
Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
|
|
574
|
+
inst.maxValue =
|
|
575
|
+
Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
|
|
576
|
+
inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? 0.5);
|
|
577
|
+
inst.isFinite = true;
|
|
578
|
+
inst.format = bag.format ?? null;
|
|
579
|
+
}, {
|
|
580
|
+
gt(value, params) {
|
|
581
|
+
return this.check(checks.gt(value, params));
|
|
582
|
+
},
|
|
583
|
+
gte(value, params) {
|
|
584
|
+
return this.check(checks.gte(value, params));
|
|
585
|
+
},
|
|
586
|
+
min(value, params) {
|
|
587
|
+
return this.check(checks.gte(value, params));
|
|
588
|
+
},
|
|
589
|
+
lt(value, params) {
|
|
590
|
+
return this.check(checks.lt(value, params));
|
|
591
|
+
},
|
|
592
|
+
lte(value, params) {
|
|
593
|
+
return this.check(checks.lte(value, params));
|
|
594
|
+
},
|
|
595
|
+
max(value, params) {
|
|
596
|
+
return this.check(checks.lte(value, params));
|
|
597
|
+
},
|
|
598
|
+
int(params) {
|
|
599
|
+
return this.check(int(params));
|
|
600
|
+
},
|
|
601
|
+
safe(params) {
|
|
602
|
+
return this.check(int(params));
|
|
603
|
+
},
|
|
604
|
+
positive(params) {
|
|
605
|
+
return this.check(checks.gt(0, params));
|
|
606
|
+
},
|
|
607
|
+
nonnegative(params) {
|
|
608
|
+
return this.check(checks.gte(0, params));
|
|
609
|
+
},
|
|
610
|
+
negative(params) {
|
|
611
|
+
return this.check(checks.lt(0, params));
|
|
612
|
+
},
|
|
613
|
+
nonpositive(params) {
|
|
614
|
+
return this.check(checks.lte(0, params));
|
|
615
|
+
},
|
|
616
|
+
multipleOf(value, params) {
|
|
617
|
+
return this.check(checks.multipleOf(value, params));
|
|
618
|
+
},
|
|
619
|
+
step(value, params) {
|
|
620
|
+
return this.check(checks.multipleOf(value, params));
|
|
621
|
+
},
|
|
622
|
+
finite() {
|
|
623
|
+
return this;
|
|
624
|
+
},
|
|
625
|
+
});
|
|
626
|
+
export function number(params) {
|
|
627
|
+
return core._number(ZodNumber, params);
|
|
628
|
+
}
|
|
629
|
+
export const ZodNumberFormat = /*@__PURE__*/ core.$constructor("ZodNumberFormat", (inst, def) => {
|
|
630
|
+
core.$ZodNumberFormat.init(inst, def);
|
|
631
|
+
ZodNumber.init(inst, def);
|
|
632
|
+
});
|
|
633
|
+
export function int(params) {
|
|
634
|
+
return core._int(ZodNumberFormat, params);
|
|
635
|
+
}
|
|
636
|
+
export function float32(params) {
|
|
637
|
+
return core._float32(ZodNumberFormat, params);
|
|
638
|
+
}
|
|
639
|
+
export function float64(params) {
|
|
640
|
+
return core._float64(ZodNumberFormat, params);
|
|
641
|
+
}
|
|
642
|
+
export function int32(params) {
|
|
643
|
+
return core._int32(ZodNumberFormat, params);
|
|
644
|
+
}
|
|
645
|
+
export function uint32(params) {
|
|
646
|
+
return core._uint32(ZodNumberFormat, params);
|
|
647
|
+
}
|
|
648
|
+
export const ZodBoolean = /*@__PURE__*/ core.$constructor("ZodBoolean", (inst, def) => {
|
|
649
|
+
core.$ZodBoolean.init(inst, def);
|
|
650
|
+
ZodType.init(inst, def);
|
|
651
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.booleanProcessor(inst, ctx, json, params);
|
|
652
|
+
});
|
|
653
|
+
export function boolean(params) {
|
|
654
|
+
return core._boolean(ZodBoolean, params);
|
|
655
|
+
}
|
|
656
|
+
export const ZodBigInt = /*@__PURE__*/ core.$constructor("ZodBigInt", (inst, def) => {
|
|
657
|
+
core.$ZodBigInt.init(inst, def);
|
|
658
|
+
ZodType.init(inst, def);
|
|
659
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.bigintProcessor(inst, ctx, json, params);
|
|
660
|
+
const bag = inst._zod.bag;
|
|
661
|
+
inst.minValue = bag.minimum ?? null;
|
|
662
|
+
inst.maxValue = bag.maximum ?? null;
|
|
663
|
+
inst.format = bag.format ?? null;
|
|
664
|
+
}, {
|
|
665
|
+
gte(value, params) {
|
|
666
|
+
return this.check(checks.gte(value, params));
|
|
667
|
+
},
|
|
668
|
+
min(value, params) {
|
|
669
|
+
return this.check(checks.gte(value, params));
|
|
670
|
+
},
|
|
671
|
+
gt(value, params) {
|
|
672
|
+
return this.check(checks.gt(value, params));
|
|
673
|
+
},
|
|
674
|
+
lt(value, params) {
|
|
675
|
+
return this.check(checks.lt(value, params));
|
|
676
|
+
},
|
|
677
|
+
lte(value, params) {
|
|
678
|
+
return this.check(checks.lte(value, params));
|
|
679
|
+
},
|
|
680
|
+
max(value, params) {
|
|
681
|
+
return this.check(checks.lte(value, params));
|
|
682
|
+
},
|
|
683
|
+
positive(params) {
|
|
684
|
+
return this.check(checks.gt(BigInt(0), params));
|
|
685
|
+
},
|
|
686
|
+
negative(params) {
|
|
687
|
+
return this.check(checks.lt(BigInt(0), params));
|
|
688
|
+
},
|
|
689
|
+
nonpositive(params) {
|
|
690
|
+
return this.check(checks.lte(BigInt(0), params));
|
|
691
|
+
},
|
|
692
|
+
nonnegative(params) {
|
|
693
|
+
return this.check(checks.gte(BigInt(0), params));
|
|
694
|
+
},
|
|
695
|
+
multipleOf(value, params) {
|
|
696
|
+
return this.check(checks.multipleOf(value, params));
|
|
697
|
+
},
|
|
698
|
+
});
|
|
699
|
+
export function bigint(params) {
|
|
700
|
+
return core._bigint(ZodBigInt, params);
|
|
701
|
+
}
|
|
702
|
+
export const ZodBigIntFormat = /*@__PURE__*/ core.$constructor("ZodBigIntFormat", (inst, def) => {
|
|
703
|
+
core.$ZodBigIntFormat.init(inst, def);
|
|
704
|
+
ZodBigInt.init(inst, def);
|
|
705
|
+
});
|
|
706
|
+
export function int64(params) {
|
|
707
|
+
return core._int64(ZodBigIntFormat, params);
|
|
708
|
+
}
|
|
709
|
+
export function uint64(params) {
|
|
710
|
+
return core._uint64(ZodBigIntFormat, params);
|
|
711
|
+
}
|
|
712
|
+
export const ZodSymbol = /*@__PURE__*/ core.$constructor("ZodSymbol", (inst, def) => {
|
|
713
|
+
core.$ZodSymbol.init(inst, def);
|
|
714
|
+
ZodType.init(inst, def);
|
|
715
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.symbolProcessor(inst, ctx, json, params);
|
|
716
|
+
});
|
|
717
|
+
export function symbol(params) {
|
|
718
|
+
return core._symbol(ZodSymbol, params);
|
|
719
|
+
}
|
|
720
|
+
export const ZodUndefined = /*@__PURE__*/ core.$constructor("ZodUndefined", (inst, def) => {
|
|
721
|
+
core.$ZodUndefined.init(inst, def);
|
|
722
|
+
ZodType.init(inst, def);
|
|
723
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.undefinedProcessor(inst, ctx, json, params);
|
|
724
|
+
});
|
|
725
|
+
function _undefined(params) {
|
|
726
|
+
return core._undefined(ZodUndefined, params);
|
|
727
|
+
}
|
|
728
|
+
export { _undefined as undefined };
|
|
729
|
+
export const ZodNull = /*@__PURE__*/ core.$constructor("ZodNull", (inst, def) => {
|
|
730
|
+
core.$ZodNull.init(inst, def);
|
|
731
|
+
ZodType.init(inst, def);
|
|
732
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.nullProcessor(inst, ctx, json, params);
|
|
733
|
+
});
|
|
734
|
+
function _null(params) {
|
|
735
|
+
return core._null(ZodNull, params);
|
|
736
|
+
}
|
|
737
|
+
export { _null as null };
|
|
738
|
+
export const ZodAny = /*@__PURE__*/ core.$constructor("ZodAny", (inst, def) => {
|
|
739
|
+
core.$ZodAny.init(inst, def);
|
|
740
|
+
ZodType.init(inst, def);
|
|
741
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.anyProcessor(inst, ctx, json, params);
|
|
742
|
+
});
|
|
743
|
+
export function any() {
|
|
744
|
+
return core._any(ZodAny);
|
|
745
|
+
}
|
|
746
|
+
export const ZodUnknown = /*@__PURE__*/ core.$constructor("ZodUnknown", (inst, def) => {
|
|
747
|
+
core.$ZodUnknown.init(inst, def);
|
|
748
|
+
ZodType.init(inst, def);
|
|
749
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.unknownProcessor(inst, ctx, json, params);
|
|
750
|
+
});
|
|
751
|
+
export function unknown() {
|
|
752
|
+
return core._unknown(ZodUnknown);
|
|
753
|
+
}
|
|
754
|
+
export const ZodNever = /*@__PURE__*/ core.$constructor("ZodNever", (inst, def) => {
|
|
755
|
+
core.$ZodNever.init(inst, def);
|
|
756
|
+
ZodType.init(inst, def);
|
|
757
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.neverProcessor(inst, ctx, json, params);
|
|
758
|
+
});
|
|
759
|
+
export function never(params) {
|
|
760
|
+
return core._never(ZodNever, params);
|
|
761
|
+
}
|
|
762
|
+
export const ZodVoid = /*@__PURE__*/ core.$constructor("ZodVoid", (inst, def) => {
|
|
763
|
+
core.$ZodVoid.init(inst, def);
|
|
764
|
+
ZodType.init(inst, def);
|
|
765
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.voidProcessor(inst, ctx, json, params);
|
|
766
|
+
});
|
|
767
|
+
function _void(params) {
|
|
768
|
+
return core._void(ZodVoid, params);
|
|
769
|
+
}
|
|
770
|
+
export { _void as void };
|
|
771
|
+
export const ZodDate = /*@__PURE__*/ core.$constructor("ZodDate", (inst, def) => {
|
|
772
|
+
core.$ZodDate.init(inst, def);
|
|
773
|
+
ZodType.init(inst, def);
|
|
774
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.dateProcessor(inst, ctx, json, params);
|
|
775
|
+
inst.min = (value, params) => inst.check(checks.gte(value, params));
|
|
776
|
+
inst.max = (value, params) => inst.check(checks.lte(value, params));
|
|
777
|
+
const c = inst._zod.bag;
|
|
778
|
+
inst.minDate = c.minimum ? new Date(c.minimum) : null;
|
|
779
|
+
inst.maxDate = c.maximum ? new Date(c.maximum) : null;
|
|
780
|
+
});
|
|
781
|
+
export function date(params) {
|
|
782
|
+
return core._date(ZodDate, params);
|
|
783
|
+
}
|
|
784
|
+
export const ZodArray = /*@__PURE__*/ core.$constructor("ZodArray", (inst, def) => {
|
|
785
|
+
_ensureDefaultMemoizer();
|
|
786
|
+
core.$ZodArray.init(inst, def);
|
|
787
|
+
ZodType.init(inst, def);
|
|
788
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.arrayProcessor(inst, ctx, json, params);
|
|
789
|
+
inst.element = def.element;
|
|
790
|
+
}, {
|
|
791
|
+
min(n, params) {
|
|
792
|
+
return this.check(checks.minLength(n, params));
|
|
793
|
+
},
|
|
794
|
+
nonempty(params) {
|
|
795
|
+
return this.check(checks.minLength(1, params));
|
|
796
|
+
},
|
|
797
|
+
max(n, params) {
|
|
798
|
+
return this.check(checks.maxLength(n, params));
|
|
799
|
+
},
|
|
800
|
+
length(n, params) {
|
|
801
|
+
return this.check(checks.length(n, params));
|
|
802
|
+
},
|
|
803
|
+
unwrap() {
|
|
804
|
+
return this.element;
|
|
805
|
+
},
|
|
806
|
+
});
|
|
807
|
+
export function array(element, params) {
|
|
808
|
+
return core._array(ZodArray, element, params);
|
|
809
|
+
}
|
|
810
|
+
// .keyof
|
|
811
|
+
export function keyof(schema) {
|
|
812
|
+
const shape = schema._zod.def.shape;
|
|
813
|
+
return _enum(Object.keys(shape));
|
|
814
|
+
}
|
|
815
|
+
export const ZodObject = /*@__PURE__*/ core.$constructor("ZodObject", (inst, def) => {
|
|
816
|
+
_ensureDefaultMemoizer();
|
|
817
|
+
core.$ZodObjectJIT.init(inst, def);
|
|
818
|
+
ZodType.init(inst, def);
|
|
819
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.objectProcessor(inst, ctx, json, params);
|
|
820
|
+
util.installLazyProp(inst, "shape", (self) => self._zod.def.shape, false);
|
|
821
|
+
}, {
|
|
822
|
+
keyof() {
|
|
823
|
+
return _enum(Object.keys(this._zod.def.shape));
|
|
824
|
+
},
|
|
825
|
+
catchall(catchall) {
|
|
826
|
+
return this.clone({ ...this._zod.def, catchall: catchall });
|
|
827
|
+
},
|
|
828
|
+
passthrough() {
|
|
829
|
+
return this.clone({ ...this._zod.def, catchall: unknown() });
|
|
830
|
+
},
|
|
831
|
+
loose() {
|
|
832
|
+
return this.clone({ ...this._zod.def, catchall: unknown() });
|
|
833
|
+
},
|
|
834
|
+
strict() {
|
|
835
|
+
return this.clone({ ...this._zod.def, catchall: never() });
|
|
836
|
+
},
|
|
837
|
+
strip() {
|
|
838
|
+
return this.clone({ ...this._zod.def, catchall: undefined });
|
|
839
|
+
},
|
|
840
|
+
extend(incoming) {
|
|
841
|
+
return util.extend(this, incoming);
|
|
842
|
+
},
|
|
843
|
+
safeExtend(incoming) {
|
|
844
|
+
return util.safeExtend(this, incoming);
|
|
845
|
+
},
|
|
846
|
+
merge(other) {
|
|
847
|
+
return util.merge(this, other);
|
|
848
|
+
},
|
|
849
|
+
pick(mask) {
|
|
850
|
+
return util.pick(this, mask);
|
|
851
|
+
},
|
|
852
|
+
omit(mask) {
|
|
853
|
+
return util.omit(this, mask);
|
|
854
|
+
},
|
|
855
|
+
partial(...args) {
|
|
856
|
+
return util.partial(ZodOptional, this, args[0]);
|
|
857
|
+
},
|
|
858
|
+
exactPartial(...args) {
|
|
859
|
+
return util.partial(ZodExactOptional, this, args[0], "exactPartial");
|
|
860
|
+
},
|
|
861
|
+
required(...args) {
|
|
862
|
+
return util.required(ZodNonOptional, this, args[0]);
|
|
863
|
+
},
|
|
864
|
+
});
|
|
865
|
+
export function object(shape, params) {
|
|
866
|
+
const def = {
|
|
867
|
+
type: "object",
|
|
868
|
+
shape: shape ?? {},
|
|
869
|
+
...util.normalizeParams(params),
|
|
870
|
+
};
|
|
871
|
+
return new ZodObject(def);
|
|
872
|
+
}
|
|
873
|
+
// strictObject
|
|
874
|
+
export function strictObject(shape, params) {
|
|
875
|
+
return new ZodObject({
|
|
876
|
+
type: "object",
|
|
877
|
+
shape,
|
|
878
|
+
catchall: never(),
|
|
879
|
+
...util.normalizeParams(params),
|
|
880
|
+
});
|
|
881
|
+
}
|
|
882
|
+
// looseObject
|
|
883
|
+
export function looseObject(shape, params) {
|
|
884
|
+
return new ZodObject({
|
|
885
|
+
type: "object",
|
|
886
|
+
shape,
|
|
887
|
+
catchall: unknown(),
|
|
888
|
+
...util.normalizeParams(params),
|
|
889
|
+
});
|
|
890
|
+
}
|
|
891
|
+
export const ZodUnion = /*@__PURE__*/ core.$constructor("ZodUnion", (inst, def) => {
|
|
892
|
+
core.$ZodUnion.init(inst, def);
|
|
893
|
+
ZodType.init(inst, def);
|
|
894
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.unionProcessor(inst, ctx, json, params);
|
|
895
|
+
inst.options = def.options;
|
|
896
|
+
});
|
|
897
|
+
export function union(options, params) {
|
|
898
|
+
return new ZodUnion({
|
|
899
|
+
type: "union",
|
|
900
|
+
options: options,
|
|
901
|
+
...util.normalizeParams(params),
|
|
902
|
+
});
|
|
903
|
+
}
|
|
904
|
+
export const ZodXor = /*@__PURE__*/ core.$constructor("ZodXor", (inst, def) => {
|
|
905
|
+
ZodUnion.init(inst, def);
|
|
906
|
+
core.$ZodXor.init(inst, def);
|
|
907
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.unionProcessor(inst, ctx, json, params);
|
|
908
|
+
inst.options = def.options;
|
|
909
|
+
});
|
|
910
|
+
/** Creates an exclusive union (XOR) where exactly one option must match.
|
|
911
|
+
* Unlike regular unions that succeed when any option matches, xor fails if
|
|
912
|
+
* zero or more than one option matches the input. */
|
|
913
|
+
export function xor(options, params) {
|
|
914
|
+
return new ZodXor({
|
|
915
|
+
type: "union",
|
|
916
|
+
options: options,
|
|
917
|
+
inclusive: false,
|
|
918
|
+
...util.normalizeParams(params),
|
|
919
|
+
});
|
|
920
|
+
}
|
|
921
|
+
export const ZodDiscriminatedUnion = /*@__PURE__*/ core.$constructor("ZodDiscriminatedUnion", (inst, def) => {
|
|
922
|
+
ZodUnion.init(inst, def);
|
|
923
|
+
core.$ZodDiscriminatedUnion.init(inst, def);
|
|
924
|
+
});
|
|
925
|
+
export function discriminatedUnion(discriminator, options, params) {
|
|
926
|
+
// const [options, params] = args;
|
|
927
|
+
return new ZodDiscriminatedUnion({
|
|
928
|
+
type: "union",
|
|
929
|
+
options: options,
|
|
930
|
+
discriminator,
|
|
931
|
+
...util.normalizeParams(params),
|
|
932
|
+
});
|
|
933
|
+
}
|
|
934
|
+
export const ZodIntersection = /*@__PURE__*/ core.$constructor("ZodIntersection", (inst, def) => {
|
|
935
|
+
core.$ZodIntersection.init(inst, def);
|
|
936
|
+
ZodType.init(inst, def);
|
|
937
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.intersectionProcessor(inst, ctx, json, params);
|
|
938
|
+
});
|
|
939
|
+
export function intersection(left, right) {
|
|
940
|
+
return new ZodIntersection({
|
|
941
|
+
type: "intersection",
|
|
942
|
+
left: left,
|
|
943
|
+
right: right,
|
|
944
|
+
});
|
|
945
|
+
}
|
|
946
|
+
export const ZodTuple = /*@__PURE__*/ core.$constructor("ZodTuple", (inst, def) => {
|
|
947
|
+
_ensureDefaultMemoizer();
|
|
948
|
+
core.$ZodTuple.init(inst, def);
|
|
949
|
+
ZodType.init(inst, def);
|
|
950
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.tupleProcessor(inst, ctx, json, params);
|
|
951
|
+
}, {
|
|
952
|
+
rest(rest) {
|
|
953
|
+
return this.clone({
|
|
954
|
+
...this._zod.def,
|
|
955
|
+
rest: rest,
|
|
956
|
+
});
|
|
957
|
+
},
|
|
958
|
+
partial() {
|
|
959
|
+
const def = this._zod.def;
|
|
960
|
+
// a refinement was authored against the full arity; partialing would run it on a shorter array
|
|
961
|
+
if (def.checks?.length)
|
|
962
|
+
throw new Error(".partial() cannot be used on tuple schemas containing refinements");
|
|
963
|
+
return this.clone({
|
|
964
|
+
...def,
|
|
965
|
+
items: def.items.map((item) => new ZodOptional({ type: "optional", innerType: item })),
|
|
966
|
+
});
|
|
967
|
+
},
|
|
968
|
+
});
|
|
969
|
+
export function tuple(items, _paramsOrRest, _params) {
|
|
970
|
+
const hasRest = _paramsOrRest instanceof core.$ZodType;
|
|
971
|
+
const params = hasRest ? _params : _paramsOrRest;
|
|
972
|
+
const rest = hasRest ? _paramsOrRest : null;
|
|
973
|
+
return new ZodTuple({
|
|
974
|
+
type: "tuple",
|
|
975
|
+
items: items,
|
|
976
|
+
rest,
|
|
977
|
+
...util.normalizeParams(params),
|
|
978
|
+
});
|
|
979
|
+
}
|
|
980
|
+
export const ZodRecord = /*@__PURE__*/ core.$constructor("ZodRecord", (inst, def) => {
|
|
981
|
+
_ensureDefaultMemoizer();
|
|
982
|
+
core.$ZodRecord.init(inst, def);
|
|
983
|
+
ZodType.init(inst, def);
|
|
984
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.recordProcessor(inst, ctx, json, params);
|
|
985
|
+
inst.keyType = def.keyType;
|
|
986
|
+
inst.valueType = def.valueType;
|
|
987
|
+
});
|
|
988
|
+
export function record(keyType, valueType, params) {
|
|
989
|
+
// v3-compat: z.record(valueType, params?) — defaults keyType to z.string()
|
|
990
|
+
if (!valueType || !valueType._zod) {
|
|
991
|
+
return new ZodRecord({
|
|
992
|
+
type: "record",
|
|
993
|
+
keyType: string(),
|
|
994
|
+
valueType: keyType,
|
|
995
|
+
...util.normalizeParams(valueType),
|
|
996
|
+
});
|
|
997
|
+
}
|
|
998
|
+
return new ZodRecord({
|
|
999
|
+
type: "record",
|
|
1000
|
+
keyType,
|
|
1001
|
+
valueType: valueType,
|
|
1002
|
+
...util.normalizeParams(params),
|
|
1003
|
+
});
|
|
1004
|
+
}
|
|
1005
|
+
// type alksjf = core.output<core.$ZodRecordKey>;
|
|
1006
|
+
export function partialRecord(keyType, valueType, params) {
|
|
1007
|
+
return new ZodRecord({
|
|
1008
|
+
type: "record",
|
|
1009
|
+
keyType,
|
|
1010
|
+
valueType: valueType,
|
|
1011
|
+
...util.normalizeParams(params),
|
|
1012
|
+
partial: true,
|
|
1013
|
+
});
|
|
1014
|
+
}
|
|
1015
|
+
export function looseRecord(keyType, valueType, params) {
|
|
1016
|
+
return new ZodRecord({
|
|
1017
|
+
type: "record",
|
|
1018
|
+
keyType,
|
|
1019
|
+
valueType: valueType,
|
|
1020
|
+
mode: "loose",
|
|
1021
|
+
...util.normalizeParams(params),
|
|
1022
|
+
});
|
|
1023
|
+
}
|
|
1024
|
+
export const ZodMap = /*@__PURE__*/ core.$constructor("ZodMap", (inst, def) => {
|
|
1025
|
+
_ensureDefaultMemoizer();
|
|
1026
|
+
core.$ZodMap.init(inst, def);
|
|
1027
|
+
ZodType.init(inst, def);
|
|
1028
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.mapProcessor(inst, ctx, json, params);
|
|
1029
|
+
inst.keyType = def.keyType;
|
|
1030
|
+
inst.valueType = def.valueType;
|
|
1031
|
+
inst.min = (...args) => inst.check(core._minSize(...args));
|
|
1032
|
+
inst.nonempty = (params) => inst.check(core._minSize(1, params));
|
|
1033
|
+
inst.max = (...args) => inst.check(core._maxSize(...args));
|
|
1034
|
+
inst.size = (...args) => inst.check(core._size(...args));
|
|
1035
|
+
});
|
|
1036
|
+
export function map(keyType, valueType, params) {
|
|
1037
|
+
return new ZodMap({
|
|
1038
|
+
type: "map",
|
|
1039
|
+
keyType: keyType,
|
|
1040
|
+
valueType: valueType,
|
|
1041
|
+
...util.normalizeParams(params),
|
|
1042
|
+
});
|
|
1043
|
+
}
|
|
1044
|
+
export const ZodSet = /*@__PURE__*/ core.$constructor("ZodSet", (inst, def) => {
|
|
1045
|
+
_ensureDefaultMemoizer();
|
|
1046
|
+
core.$ZodSet.init(inst, def);
|
|
1047
|
+
ZodType.init(inst, def);
|
|
1048
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.setProcessor(inst, ctx, json, params);
|
|
1049
|
+
inst.min = (...args) => inst.check(core._minSize(...args));
|
|
1050
|
+
inst.nonempty = (params) => inst.check(core._minSize(1, params));
|
|
1051
|
+
inst.max = (...args) => inst.check(core._maxSize(...args));
|
|
1052
|
+
inst.size = (...args) => inst.check(core._size(...args));
|
|
1053
|
+
});
|
|
1054
|
+
export function set(valueType, params) {
|
|
1055
|
+
return new ZodSet({
|
|
1056
|
+
type: "set",
|
|
1057
|
+
valueType: valueType,
|
|
1058
|
+
...util.normalizeParams(params),
|
|
1059
|
+
});
|
|
1060
|
+
}
|
|
1061
|
+
export const ZodEnum = /*@__PURE__*/ core.$constructor("ZodEnum", (inst, def) => {
|
|
1062
|
+
core.$ZodEnum.init(inst, def);
|
|
1063
|
+
ZodType.init(inst, def);
|
|
1064
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.enumProcessor(inst, ctx, json, params);
|
|
1065
|
+
inst.enum = def.entries;
|
|
1066
|
+
inst.options = Object.values(def.entries);
|
|
1067
|
+
const keys = new Set(Object.keys(def.entries));
|
|
1068
|
+
inst.extract = (values, params) => {
|
|
1069
|
+
const newEntries = {};
|
|
1070
|
+
for (const value of values) {
|
|
1071
|
+
if (keys.has(value)) {
|
|
1072
|
+
newEntries[value] = def.entries[value];
|
|
1073
|
+
}
|
|
1074
|
+
else
|
|
1075
|
+
throw new Error(`Key ${value} not found in enum`);
|
|
1076
|
+
}
|
|
1077
|
+
return new ZodEnum({
|
|
1078
|
+
...def,
|
|
1079
|
+
checks: [],
|
|
1080
|
+
...util.normalizeParams(params),
|
|
1081
|
+
entries: newEntries,
|
|
1082
|
+
});
|
|
1083
|
+
};
|
|
1084
|
+
inst.exclude = (values, params) => {
|
|
1085
|
+
const newEntries = { ...def.entries };
|
|
1086
|
+
for (const value of values) {
|
|
1087
|
+
if (keys.has(value)) {
|
|
1088
|
+
delete newEntries[value];
|
|
1089
|
+
}
|
|
1090
|
+
else
|
|
1091
|
+
throw new Error(`Key ${value} not found in enum`);
|
|
1092
|
+
}
|
|
1093
|
+
return new ZodEnum({
|
|
1094
|
+
...def,
|
|
1095
|
+
checks: [],
|
|
1096
|
+
...util.normalizeParams(params),
|
|
1097
|
+
entries: newEntries,
|
|
1098
|
+
});
|
|
1099
|
+
};
|
|
1100
|
+
});
|
|
1101
|
+
function _enum(values, params) {
|
|
1102
|
+
const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
|
|
1103
|
+
return new ZodEnum({
|
|
1104
|
+
type: "enum",
|
|
1105
|
+
entries,
|
|
1106
|
+
...util.normalizeParams(params),
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
1109
|
+
export { _enum as enum };
|
|
1110
|
+
/** @deprecated This API has been merged into `z.enum()`. Use `z.enum()` instead.
|
|
1111
|
+
*
|
|
1112
|
+
* ```ts
|
|
1113
|
+
* enum Colors { red, green, blue }
|
|
1114
|
+
* z.enum(Colors);
|
|
1115
|
+
* ```
|
|
1116
|
+
*/
|
|
1117
|
+
export function nativeEnum(entries, params) {
|
|
1118
|
+
return new ZodEnum({
|
|
1119
|
+
type: "enum",
|
|
1120
|
+
entries,
|
|
1121
|
+
...util.normalizeParams(params),
|
|
1122
|
+
});
|
|
1123
|
+
}
|
|
1124
|
+
export const ZodLiteral = /*@__PURE__*/ core.$constructor("ZodLiteral", (inst, def) => {
|
|
1125
|
+
core.$ZodLiteral.init(inst, def);
|
|
1126
|
+
ZodType.init(inst, def);
|
|
1127
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.literalProcessor(inst, ctx, json, params);
|
|
1128
|
+
inst.values = new Set(def.values);
|
|
1129
|
+
Object.defineProperty(inst, "value", {
|
|
1130
|
+
get() {
|
|
1131
|
+
if (def.values.length > 1) {
|
|
1132
|
+
throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
|
|
1133
|
+
}
|
|
1134
|
+
return def.values[0];
|
|
1135
|
+
},
|
|
1136
|
+
});
|
|
1137
|
+
});
|
|
1138
|
+
export function literal(value, params) {
|
|
1139
|
+
return new ZodLiteral({
|
|
1140
|
+
type: "literal",
|
|
1141
|
+
values: Array.isArray(value) ? value : [value],
|
|
1142
|
+
...util.normalizeParams(params),
|
|
1143
|
+
});
|
|
1144
|
+
}
|
|
1145
|
+
export const ZodFile = /*@__PURE__*/ core.$constructor("ZodFile", (inst, def) => {
|
|
1146
|
+
core.$ZodFile.init(inst, def);
|
|
1147
|
+
ZodType.init(inst, def);
|
|
1148
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.fileProcessor(inst, ctx, json, params);
|
|
1149
|
+
inst.min = (size, params) => inst.check(core._minSize(size, params));
|
|
1150
|
+
inst.max = (size, params) => inst.check(core._maxSize(size, params));
|
|
1151
|
+
inst.mime = (types, params) => inst.check(core._mime(Array.isArray(types) ? types : [types], params));
|
|
1152
|
+
});
|
|
1153
|
+
export function file(params) {
|
|
1154
|
+
return core._file(ZodFile, params);
|
|
1155
|
+
}
|
|
1156
|
+
export const ZodTransform = /*@__PURE__*/ core.$constructor("ZodTransform", (inst, def) => {
|
|
1157
|
+
_ensureDefaultMemoizer();
|
|
1158
|
+
core.$ZodTransform.init(inst, def);
|
|
1159
|
+
ZodType.init(inst, def);
|
|
1160
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.transformProcessor(inst, ctx, json, params);
|
|
1161
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
1162
|
+
if (_ctx.direction === "backward") {
|
|
1163
|
+
throw new core.$ZodEncodeError(inst.constructor.name);
|
|
1164
|
+
}
|
|
1165
|
+
payload.addIssue = (issue) => {
|
|
1166
|
+
if (typeof issue === "string") {
|
|
1167
|
+
payload.issues.push(util.issue(issue, payload.value, def));
|
|
1168
|
+
}
|
|
1169
|
+
else {
|
|
1170
|
+
// for Zod 3 backwards compatibility
|
|
1171
|
+
const _issue = issue;
|
|
1172
|
+
if (_issue.fatal)
|
|
1173
|
+
_issue.continue = false;
|
|
1174
|
+
_issue.code ?? (_issue.code = "custom");
|
|
1175
|
+
if (!("input" in _issue))
|
|
1176
|
+
_issue.input = payload.value;
|
|
1177
|
+
_issue.inst ?? (_issue.inst = inst);
|
|
1178
|
+
// _issue.continue ??= true;
|
|
1179
|
+
payload.issues.push(util.issue(_issue));
|
|
1180
|
+
}
|
|
1181
|
+
};
|
|
1182
|
+
const output = def.transform(payload.value, payload);
|
|
1183
|
+
if (output instanceof Promise) {
|
|
1184
|
+
return output.then((output) => {
|
|
1185
|
+
payload.value = output;
|
|
1186
|
+
return payload;
|
|
1187
|
+
});
|
|
1188
|
+
}
|
|
1189
|
+
payload.value = output;
|
|
1190
|
+
return payload;
|
|
1191
|
+
};
|
|
1192
|
+
});
|
|
1193
|
+
export function transform(fn) {
|
|
1194
|
+
return new ZodTransform({
|
|
1195
|
+
type: "transform",
|
|
1196
|
+
transform: fn,
|
|
1197
|
+
});
|
|
1198
|
+
}
|
|
1199
|
+
export const ZodOptional = /*@__PURE__*/ core.$constructor("ZodOptional", (inst, def) => {
|
|
1200
|
+
core.$ZodOptional.init(inst, def);
|
|
1201
|
+
ZodType.init(inst, def);
|
|
1202
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.optionalProcessor(inst, ctx, json, params);
|
|
1203
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
1204
|
+
});
|
|
1205
|
+
export function optional(innerType) {
|
|
1206
|
+
return new ZodOptional({
|
|
1207
|
+
type: "optional",
|
|
1208
|
+
innerType: innerType,
|
|
1209
|
+
});
|
|
1210
|
+
}
|
|
1211
|
+
export const ZodExactOptional = /*@__PURE__*/ core.$constructor("ZodExactOptional", (inst, def) => {
|
|
1212
|
+
core.$ZodExactOptional.init(inst, def);
|
|
1213
|
+
ZodType.init(inst, def);
|
|
1214
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.optionalProcessor(inst, ctx, json, params);
|
|
1215
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
1216
|
+
});
|
|
1217
|
+
export function exactOptional(innerType) {
|
|
1218
|
+
return new ZodExactOptional({
|
|
1219
|
+
type: "optional",
|
|
1220
|
+
innerType: innerType,
|
|
1221
|
+
});
|
|
1222
|
+
}
|
|
1223
|
+
export const ZodNullable = /*@__PURE__*/ core.$constructor("ZodNullable", (inst, def) => {
|
|
1224
|
+
core.$ZodNullable.init(inst, def);
|
|
1225
|
+
ZodType.init(inst, def);
|
|
1226
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.nullableProcessor(inst, ctx, json, params);
|
|
1227
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
1228
|
+
});
|
|
1229
|
+
export function nullable(innerType) {
|
|
1230
|
+
return new ZodNullable({
|
|
1231
|
+
type: "nullable",
|
|
1232
|
+
innerType: innerType,
|
|
1233
|
+
});
|
|
1234
|
+
}
|
|
1235
|
+
// nullish
|
|
1236
|
+
export function nullish(innerType) {
|
|
1237
|
+
return optional(nullable(innerType));
|
|
1238
|
+
}
|
|
1239
|
+
export const ZodDefault = /*@__PURE__*/ core.$constructor("ZodDefault", (inst, def) => {
|
|
1240
|
+
core.$ZodDefault.init(inst, def);
|
|
1241
|
+
ZodType.init(inst, def);
|
|
1242
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.defaultProcessor(inst, ctx, json, params);
|
|
1243
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
1244
|
+
inst.removeDefault = inst.unwrap;
|
|
1245
|
+
});
|
|
1246
|
+
export function _default(innerType, defaultValue) {
|
|
1247
|
+
return new ZodDefault({
|
|
1248
|
+
type: "default",
|
|
1249
|
+
innerType: innerType,
|
|
1250
|
+
get defaultValue() {
|
|
1251
|
+
return typeof defaultValue === "function" ? defaultValue() : util.shallowClone(defaultValue);
|
|
1252
|
+
},
|
|
1253
|
+
});
|
|
1254
|
+
}
|
|
1255
|
+
export const ZodPrefault = /*@__PURE__*/ core.$constructor("ZodPrefault", (inst, def) => {
|
|
1256
|
+
core.$ZodPrefault.init(inst, def);
|
|
1257
|
+
ZodType.init(inst, def);
|
|
1258
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.prefaultProcessor(inst, ctx, json, params);
|
|
1259
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
1260
|
+
});
|
|
1261
|
+
export function prefault(innerType, defaultValue) {
|
|
1262
|
+
return new ZodPrefault({
|
|
1263
|
+
type: "prefault",
|
|
1264
|
+
innerType: innerType,
|
|
1265
|
+
get defaultValue() {
|
|
1266
|
+
return typeof defaultValue === "function" ? defaultValue() : util.shallowClone(defaultValue);
|
|
1267
|
+
},
|
|
1268
|
+
});
|
|
1269
|
+
}
|
|
1270
|
+
export const ZodNonOptional = /*@__PURE__*/ core.$constructor("ZodNonOptional", (inst, def) => {
|
|
1271
|
+
core.$ZodNonOptional.init(inst, def);
|
|
1272
|
+
ZodType.init(inst, def);
|
|
1273
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.nonoptionalProcessor(inst, ctx, json, params);
|
|
1274
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
1275
|
+
});
|
|
1276
|
+
export function nonoptional(innerType, params) {
|
|
1277
|
+
return new ZodNonOptional({
|
|
1278
|
+
type: "nonoptional",
|
|
1279
|
+
innerType: innerType,
|
|
1280
|
+
...util.normalizeParams(params),
|
|
1281
|
+
});
|
|
1282
|
+
}
|
|
1283
|
+
export const ZodSuccess = /*@__PURE__*/ core.$constructor("ZodSuccess", (inst, def) => {
|
|
1284
|
+
core.$ZodSuccess.init(inst, def);
|
|
1285
|
+
ZodType.init(inst, def);
|
|
1286
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.successProcessor(inst, ctx, json, params);
|
|
1287
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
1288
|
+
});
|
|
1289
|
+
export function success(innerType) {
|
|
1290
|
+
return new ZodSuccess({
|
|
1291
|
+
type: "success",
|
|
1292
|
+
innerType: innerType,
|
|
1293
|
+
});
|
|
1294
|
+
}
|
|
1295
|
+
export const ZodCatch = /*@__PURE__*/ core.$constructor("ZodCatch", (inst, def) => {
|
|
1296
|
+
core.$ZodCatch.init(inst, def);
|
|
1297
|
+
ZodType.init(inst, def);
|
|
1298
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.catchProcessor(inst, ctx, json, params);
|
|
1299
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
1300
|
+
inst.removeCatch = inst.unwrap;
|
|
1301
|
+
});
|
|
1302
|
+
function _catch(innerType, catchValue) {
|
|
1303
|
+
return new ZodCatch({
|
|
1304
|
+
type: "catch",
|
|
1305
|
+
innerType: innerType,
|
|
1306
|
+
catchValue: (typeof catchValue === "function" ? catchValue : core.util.constantCatch(catchValue)),
|
|
1307
|
+
});
|
|
1308
|
+
}
|
|
1309
|
+
export { _catch as catch };
|
|
1310
|
+
export const ZodNaN = /*@__PURE__*/ core.$constructor("ZodNaN", (inst, def) => {
|
|
1311
|
+
core.$ZodNaN.init(inst, def);
|
|
1312
|
+
ZodType.init(inst, def);
|
|
1313
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.nanProcessor(inst, ctx, json, params);
|
|
1314
|
+
});
|
|
1315
|
+
export function nan(params) {
|
|
1316
|
+
return core._nan(ZodNaN, params);
|
|
1317
|
+
}
|
|
1318
|
+
export const ZodPipe = /*@__PURE__*/ core.$constructor("ZodPipe", (inst, def) => {
|
|
1319
|
+
core.$ZodPipe.init(inst, def);
|
|
1320
|
+
ZodType.init(inst, def);
|
|
1321
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.pipeProcessor(inst, ctx, json, params);
|
|
1322
|
+
inst.in = def.in;
|
|
1323
|
+
inst.out = def.out;
|
|
1324
|
+
});
|
|
1325
|
+
export function pipe(in_, out) {
|
|
1326
|
+
return new ZodPipe({
|
|
1327
|
+
type: "pipe",
|
|
1328
|
+
in: in_,
|
|
1329
|
+
out: out,
|
|
1330
|
+
// ...util.normalizeParams(params),
|
|
1331
|
+
});
|
|
1332
|
+
}
|
|
1333
|
+
export const ZodCodec = /*@__PURE__*/ core.$constructor("ZodCodec", (inst, def) => {
|
|
1334
|
+
ZodPipe.init(inst, def);
|
|
1335
|
+
core.$ZodCodec.init(inst, def);
|
|
1336
|
+
});
|
|
1337
|
+
export function codec(in_, out, params) {
|
|
1338
|
+
return new ZodCodec({
|
|
1339
|
+
type: "pipe",
|
|
1340
|
+
in: in_,
|
|
1341
|
+
out: out,
|
|
1342
|
+
transform: params.decode,
|
|
1343
|
+
reverseTransform: params.encode,
|
|
1344
|
+
});
|
|
1345
|
+
}
|
|
1346
|
+
export function invertCodec(codec) {
|
|
1347
|
+
const def = codec._zod.def;
|
|
1348
|
+
return new ZodCodec({
|
|
1349
|
+
type: "pipe",
|
|
1350
|
+
in: def.out,
|
|
1351
|
+
out: def.in,
|
|
1352
|
+
transform: def.reverseTransform,
|
|
1353
|
+
reverseTransform: def.transform,
|
|
1354
|
+
});
|
|
1355
|
+
}
|
|
1356
|
+
export const ZodPreprocess = /*@__PURE__*/ core.$constructor("ZodPreprocess", (inst, def) => {
|
|
1357
|
+
ZodPipe.init(inst, def);
|
|
1358
|
+
core.$ZodPreprocess.init(inst, def);
|
|
1359
|
+
});
|
|
1360
|
+
export const ZodReadonly = /*@__PURE__*/ core.$constructor("ZodReadonly", (inst, def) => {
|
|
1361
|
+
core.$ZodReadonly.init(inst, def);
|
|
1362
|
+
ZodType.init(inst, def);
|
|
1363
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.readonlyProcessor(inst, ctx, json, params);
|
|
1364
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
1365
|
+
});
|
|
1366
|
+
export function readonly(innerType) {
|
|
1367
|
+
return new ZodReadonly({
|
|
1368
|
+
type: "readonly",
|
|
1369
|
+
innerType: innerType,
|
|
1370
|
+
});
|
|
1371
|
+
}
|
|
1372
|
+
export const ZodTemplateLiteral = /*@__PURE__*/ core.$constructor("ZodTemplateLiteral", (inst, def) => {
|
|
1373
|
+
core.$ZodTemplateLiteral.init(inst, def);
|
|
1374
|
+
ZodType.init(inst, def);
|
|
1375
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.templateLiteralProcessor(inst, ctx, json, params);
|
|
1376
|
+
});
|
|
1377
|
+
export function templateLiteral(parts, params) {
|
|
1378
|
+
return new ZodTemplateLiteral({
|
|
1379
|
+
type: "template_literal",
|
|
1380
|
+
parts,
|
|
1381
|
+
...util.normalizeParams(params),
|
|
1382
|
+
});
|
|
1383
|
+
}
|
|
1384
|
+
export const ZodLazy = /*@__PURE__*/ core.$constructor("ZodLazy", (inst, def) => {
|
|
1385
|
+
core.$ZodLazy.init(inst, def);
|
|
1386
|
+
ZodType.init(inst, def);
|
|
1387
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.lazyProcessor(inst, ctx, json, params);
|
|
1388
|
+
inst.unwrap = () => inst._zod.def.getter();
|
|
1389
|
+
});
|
|
1390
|
+
export function lazy(getter) {
|
|
1391
|
+
return new ZodLazy({
|
|
1392
|
+
type: "lazy",
|
|
1393
|
+
getter: getter,
|
|
1394
|
+
});
|
|
1395
|
+
}
|
|
1396
|
+
export const ZodPromise = /*@__PURE__*/ core.$constructor("ZodPromise", (inst, def) => {
|
|
1397
|
+
core.$ZodPromise.init(inst, def);
|
|
1398
|
+
ZodType.init(inst, def);
|
|
1399
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.promiseProcessor(inst, ctx, json, params);
|
|
1400
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
1401
|
+
});
|
|
1402
|
+
export function promise(innerType) {
|
|
1403
|
+
return new ZodPromise({
|
|
1404
|
+
type: "promise",
|
|
1405
|
+
innerType: innerType,
|
|
1406
|
+
});
|
|
1407
|
+
}
|
|
1408
|
+
export const ZodFunction = /*@__PURE__*/ core.$constructor("ZodFunction", (inst, def) => {
|
|
1409
|
+
core.$ZodFunction.init(inst, def);
|
|
1410
|
+
ZodType.init(inst, def);
|
|
1411
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.functionProcessor(inst, ctx, json, params);
|
|
1412
|
+
});
|
|
1413
|
+
export function _function(params) {
|
|
1414
|
+
return new ZodFunction({
|
|
1415
|
+
type: "function",
|
|
1416
|
+
input: Array.isArray(params?.input) ? tuple(params?.input) : (params?.input ?? array(unknown())),
|
|
1417
|
+
output: params?.output ?? unknown(),
|
|
1418
|
+
});
|
|
1419
|
+
}
|
|
1420
|
+
export { _function as function };
|
|
1421
|
+
export const ZodCustom = /*@__PURE__*/ core.$constructor("ZodCustom", (inst, def) => {
|
|
1422
|
+
core.$ZodCustom.init(inst, def);
|
|
1423
|
+
ZodType.init(inst, def);
|
|
1424
|
+
inst._zod.processJSONSchema = (ctx, json, params) => processors.customProcessor(inst, ctx, json, params);
|
|
1425
|
+
});
|
|
1426
|
+
// custom checks
|
|
1427
|
+
export function check(fn) {
|
|
1428
|
+
const ch = new core.$ZodCheck({
|
|
1429
|
+
check: "custom",
|
|
1430
|
+
// ...util.normalizeParams(params),
|
|
1431
|
+
});
|
|
1432
|
+
ch._zod.check = fn;
|
|
1433
|
+
return ch;
|
|
1434
|
+
}
|
|
1435
|
+
export function custom(fn, _params) {
|
|
1436
|
+
return core._custom(ZodCustom, fn ?? (() => true), _params);
|
|
1437
|
+
}
|
|
1438
|
+
export function refine(fn, _params = {}) {
|
|
1439
|
+
return core._refine(ZodCustom, fn, _params);
|
|
1440
|
+
}
|
|
1441
|
+
// superRefine
|
|
1442
|
+
export function superRefine(fn, params) {
|
|
1443
|
+
return core._superRefine(fn, params);
|
|
1444
|
+
}
|
|
1445
|
+
// Re-export describe and meta from core
|
|
1446
|
+
export const describe = core.describe;
|
|
1447
|
+
export const meta = core.meta;
|
|
1448
|
+
function _instanceof(cls, params = {}) {
|
|
1449
|
+
const inst = new ZodCustom({
|
|
1450
|
+
type: "custom",
|
|
1451
|
+
check: "custom",
|
|
1452
|
+
fn: (data) => data instanceof cls,
|
|
1453
|
+
abort: true,
|
|
1454
|
+
...util.normalizeParams(params),
|
|
1455
|
+
});
|
|
1456
|
+
inst._zod.bag.Class = cls;
|
|
1457
|
+
// Override check to emit invalid_type instead of custom
|
|
1458
|
+
inst._zod.check = (payload) => {
|
|
1459
|
+
if (!(payload.value instanceof cls)) {
|
|
1460
|
+
payload.issues.push({
|
|
1461
|
+
code: "invalid_type",
|
|
1462
|
+
expected: cls.name,
|
|
1463
|
+
input: payload.value,
|
|
1464
|
+
inst,
|
|
1465
|
+
path: [...(inst._zod.def.path ?? [])],
|
|
1466
|
+
});
|
|
1467
|
+
}
|
|
1468
|
+
};
|
|
1469
|
+
return inst;
|
|
1470
|
+
}
|
|
1471
|
+
export { _instanceof as instanceof };
|
|
1472
|
+
// stringbool
|
|
1473
|
+
export const stringbool = (...args) => core._stringbool({
|
|
1474
|
+
Codec: ZodCodec,
|
|
1475
|
+
Boolean: ZodBoolean,
|
|
1476
|
+
String: ZodString,
|
|
1477
|
+
}, ...args);
|
|
1478
|
+
export function json(params) {
|
|
1479
|
+
const jsonSchema = lazy(() => {
|
|
1480
|
+
return union([string(params), number(), boolean(), _null(), array(jsonSchema), record(string(), jsonSchema)]);
|
|
1481
|
+
});
|
|
1482
|
+
return jsonSchema;
|
|
1483
|
+
}
|
|
1484
|
+
// preprocess
|
|
1485
|
+
export function preprocess(fn, schema) {
|
|
1486
|
+
return new ZodPreprocess({
|
|
1487
|
+
type: "pipe",
|
|
1488
|
+
in: transform(fn),
|
|
1489
|
+
out: schema,
|
|
1490
|
+
});
|
|
1491
|
+
}
|