zod 3.25.0 → 3.25.3
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/commonjs/index.d.ts +3 -0
- package/dist/commonjs/index.js +22 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/commonjs/v3/ZodError.d.ts +164 -0
- package/dist/commonjs/v3/ZodError.js +137 -0
- package/dist/commonjs/v3/benchmarks/datetime.d.ts +5 -0
- package/dist/commonjs/v3/benchmarks/datetime.js +54 -0
- package/dist/commonjs/v3/benchmarks/discriminatedUnion.d.ts +5 -0
- package/dist/commonjs/v3/benchmarks/discriminatedUnion.js +79 -0
- package/dist/commonjs/v3/benchmarks/index.d.ts +1 -0
- package/dist/commonjs/v3/benchmarks/index.js +59 -0
- package/dist/commonjs/v3/benchmarks/ipv4.d.ts +5 -0
- package/dist/commonjs/v3/benchmarks/ipv4.js +54 -0
- package/dist/commonjs/v3/benchmarks/object.d.ts +5 -0
- package/dist/commonjs/v3/benchmarks/object.js +70 -0
- package/dist/commonjs/v3/benchmarks/primitives.d.ts +5 -0
- package/dist/commonjs/v3/benchmarks/primitives.js +159 -0
- package/dist/commonjs/v3/benchmarks/realworld.d.ts +5 -0
- package/dist/commonjs/v3/benchmarks/realworld.js +56 -0
- package/dist/commonjs/v3/benchmarks/string.d.ts +5 -0
- package/dist/commonjs/v3/benchmarks/string.js +55 -0
- package/dist/commonjs/v3/benchmarks/union.d.ts +5 -0
- package/dist/commonjs/v3/benchmarks/union.js +79 -0
- package/dist/commonjs/v3/errors.d.ts +5 -0
- package/dist/commonjs/v3/errors.js +17 -0
- package/dist/commonjs/v3/external.d.ts +6 -0
- package/dist/commonjs/v3/external.js +22 -0
- package/dist/commonjs/v3/helpers/enumUtil.d.ts +8 -0
- package/dist/commonjs/v3/helpers/enumUtil.js +2 -0
- package/dist/commonjs/v3/helpers/errorUtil.d.ts +9 -0
- package/dist/commonjs/v3/helpers/errorUtil.js +9 -0
- package/dist/commonjs/v3/helpers/parseUtil.d.ts +78 -0
- package/dist/commonjs/v3/helpers/parseUtil.js +124 -0
- package/dist/commonjs/v3/helpers/partialUtil.d.ts +8 -0
- package/dist/commonjs/v3/helpers/partialUtil.js +2 -0
- package/dist/commonjs/v3/helpers/typeAliases.d.ts +2 -0
- package/dist/commonjs/v3/helpers/typeAliases.js +2 -0
- package/dist/commonjs/v3/helpers/util.d.ts +85 -0
- package/dist/commonjs/v3/helpers/util.js +137 -0
- package/dist/commonjs/v3/index.d.ts +4 -0
- package/dist/commonjs/v3/index.js +43 -0
- package/dist/commonjs/v3/locales/en.d.ts +3 -0
- package/dist/commonjs/v3/locales/en.js +109 -0
- package/dist/commonjs/v3/standard-schema.d.ts +102 -0
- package/dist/commonjs/v3/standard-schema.js +2 -0
- package/dist/commonjs/v3/tests/Mocker.d.ts +17 -0
- package/dist/commonjs/v3/tests/Mocker.js +57 -0
- package/dist/commonjs/v3/tests/language-server.source.d.ts +70 -0
- package/dist/commonjs/v3/tests/language-server.source.js +81 -0
- package/dist/commonjs/v3/types.d.ts +1031 -0
- package/dist/commonjs/v3/types.js +3795 -0
- package/dist/commonjs/v4/classic/checks.d.ts +1 -0
- package/dist/commonjs/v4/classic/checks.js +32 -0
- package/dist/commonjs/v4/classic/coerce.d.ts +17 -0
- package/dist/commonjs/v4/classic/coerce.js +57 -0
- package/dist/commonjs/v4/classic/compat.d.ts +48 -0
- package/dist/commonjs/v4/classic/compat.js +73 -0
- package/dist/commonjs/v4/classic/errors.d.ts +30 -0
- package/dist/commonjs/v4/classic/errors.js +76 -0
- package/dist/commonjs/v4/classic/external.d.ts +8 -0
- package/dist/commonjs/v4/classic/external.js +68 -0
- package/dist/commonjs/v4/classic/index.d.ts +4 -0
- package/dist/commonjs/v4/classic/index.js +43 -0
- package/dist/commonjs/v4/classic/iso.d.ts +22 -0
- package/dist/commonjs/v4/classic/iso.js +70 -0
- package/dist/commonjs/v4/classic/parse.d.ts +23 -0
- package/dist/commonjs/v4/classic/parse.js +42 -0
- package/dist/commonjs/v4/classic/schemas.d.ts +653 -0
- package/dist/commonjs/v4/classic/schemas.js +1123 -0
- package/dist/commonjs/v4/core/api.d.ts +273 -0
- package/dist/commonjs/v4/core/api.js +1004 -0
- package/dist/commonjs/v4/core/checks.d.ts +277 -0
- package/dist/commonjs/v4/core/checks.js +571 -0
- package/dist/commonjs/v4/core/config.d.ts +9 -0
- package/dist/commonjs/v4/core/config.js +10 -0
- package/dist/commonjs/v4/core/core.d.ts +43 -0
- package/dist/commonjs/v4/core/core.js +59 -0
- package/dist/commonjs/v4/core/doc.d.ts +14 -0
- package/dist/commonjs/v4/core/doc.js +40 -0
- package/dist/commonjs/v4/core/errors.d.ts +204 -0
- package/dist/commonjs/v4/core/errors.js +203 -0
- package/dist/commonjs/v4/core/function.d.ts +35 -0
- package/dist/commonjs/v4/core/function.js +107 -0
- package/dist/commonjs/v4/core/index.d.ts +15 -0
- package/dist/commonjs/v4/core/index.js +54 -0
- package/dist/commonjs/v4/core/json-schema.d.ts +100 -0
- package/dist/commonjs/v4/core/json-schema.js +2 -0
- package/dist/commonjs/v4/core/parse.d.ts +25 -0
- package/dist/commonjs/v4/core/parse.js +97 -0
- package/dist/commonjs/v4/core/regexes.d.ts +62 -0
- package/dist/commonjs/v4/core/regexes.js +101 -0
- package/dist/commonjs/v4/core/registries.d.ts +32 -0
- package/dist/commonjs/v4/core/registries.js +47 -0
- package/dist/commonjs/v4/core/schemas.d.ts +975 -0
- package/dist/commonjs/v4/core/schemas.js +1781 -0
- package/dist/commonjs/v4/core/standard-schema.d.ts +55 -0
- package/dist/commonjs/v4/core/standard-schema.js +2 -0
- package/dist/commonjs/v4/core/to-json-schema.d.ts +84 -0
- package/dist/commonjs/v4/core/to-json-schema.js +670 -0
- package/dist/commonjs/v4/core/util.d.ts +186 -0
- package/dist/commonjs/v4/core/util.js +515 -0
- package/dist/commonjs/v4/core/versions.d.ts +5 -0
- package/dist/commonjs/v4/core/versions.js +8 -0
- package/dist/commonjs/v4/core/zsf.d.ts +91 -0
- package/dist/commonjs/v4/core/zsf.js +172 -0
- package/dist/commonjs/v4/index.d.ts +3 -0
- package/dist/commonjs/v4/index.js +22 -0
- package/dist/commonjs/v4/locales/ar.d.ts +7 -0
- package/dist/commonjs/v4/locales/ar.js +153 -0
- package/dist/commonjs/v4/locales/az.d.ts +7 -0
- package/dist/commonjs/v4/locales/az.js +152 -0
- package/dist/commonjs/v4/locales/be.d.ts +7 -0
- package/dist/commonjs/v4/locales/be.js +201 -0
- package/dist/commonjs/v4/locales/ca.d.ts +7 -0
- package/dist/commonjs/v4/locales/ca.js +155 -0
- package/dist/commonjs/v4/locales/cs.d.ts +7 -0
- package/dist/commonjs/v4/locales/cs.js +172 -0
- package/dist/commonjs/v4/locales/de.d.ts +7 -0
- package/dist/commonjs/v4/locales/de.js +153 -0
- package/dist/commonjs/v4/locales/en.d.ts +7 -0
- package/dist/commonjs/v4/locales/en.js +155 -0
- package/dist/commonjs/v4/locales/es.d.ts +7 -0
- package/dist/commonjs/v4/locales/es.js +154 -0
- package/dist/commonjs/v4/locales/fa.d.ts +7 -0
- package/dist/commonjs/v4/locales/fa.js +159 -0
- package/dist/commonjs/v4/locales/fi.d.ts +7 -0
- package/dist/commonjs/v4/locales/fi.js +159 -0
- package/dist/commonjs/v4/locales/fr.d.ts +7 -0
- package/dist/commonjs/v4/locales/fr.js +153 -0
- package/dist/commonjs/v4/locales/frCA.d.ts +7 -0
- package/dist/commonjs/v4/locales/frCA.js +154 -0
- package/dist/commonjs/v4/locales/he.d.ts +7 -0
- package/dist/commonjs/v4/locales/he.js +154 -0
- package/dist/commonjs/v4/locales/hu.d.ts +7 -0
- package/dist/commonjs/v4/locales/hu.js +154 -0
- package/dist/commonjs/v4/locales/id.d.ts +7 -0
- package/dist/commonjs/v4/locales/id.js +153 -0
- package/dist/commonjs/v4/locales/index.d.ts +34 -0
- package/dist/commonjs/v4/locales/index.js +74 -0
- package/dist/commonjs/v4/locales/it.d.ts +7 -0
- package/dist/commonjs/v4/locales/it.js +154 -0
- package/dist/commonjs/v4/locales/ja.d.ts +7 -0
- package/dist/commonjs/v4/locales/ja.js +152 -0
- package/dist/commonjs/v4/locales/ko.d.ts +7 -0
- package/dist/commonjs/v4/locales/ko.js +158 -0
- package/dist/commonjs/v4/locales/mk.d.ts +7 -0
- package/dist/commonjs/v4/locales/mk.js +155 -0
- package/dist/commonjs/v4/locales/ms.d.ts +7 -0
- package/dist/commonjs/v4/locales/ms.js +153 -0
- package/dist/commonjs/v4/locales/no.d.ts +7 -0
- package/dist/commonjs/v4/locales/no.js +153 -0
- package/dist/commonjs/v4/locales/ota.d.ts +7 -0
- package/dist/commonjs/v4/locales/ota.js +154 -0
- package/dist/commonjs/v4/locales/pl.d.ts +7 -0
- package/dist/commonjs/v4/locales/pl.js +154 -0
- package/dist/commonjs/v4/locales/pt.d.ts +7 -0
- package/dist/commonjs/v4/locales/pt.js +153 -0
- package/dist/commonjs/v4/locales/ru.d.ts +7 -0
- package/dist/commonjs/v4/locales/ru.js +201 -0
- package/dist/commonjs/v4/locales/sl.d.ts +7 -0
- package/dist/commonjs/v4/locales/sl.js +154 -0
- package/dist/commonjs/v4/locales/ta.d.ts +7 -0
- package/dist/commonjs/v4/locales/ta.js +154 -0
- package/dist/commonjs/v4/locales/th.d.ts +7 -0
- package/dist/commonjs/v4/locales/th.js +154 -0
- package/dist/commonjs/v4/locales/tr.d.ts +7 -0
- package/dist/commonjs/v4/locales/tr.js +152 -0
- package/dist/commonjs/v4/locales/ua.d.ts +7 -0
- package/dist/commonjs/v4/locales/ua.js +154 -0
- package/dist/commonjs/v4/locales/ur.d.ts +7 -0
- package/dist/commonjs/v4/locales/ur.js +154 -0
- package/dist/commonjs/v4/locales/vi.d.ts +7 -0
- package/dist/commonjs/v4/locales/vi.js +153 -0
- package/dist/commonjs/v4/locales/zh-CN.d.ts +7 -0
- package/dist/commonjs/v4/locales/zh-CN.js +153 -0
- package/dist/commonjs/v4/locales/zh-tw.d.ts +7 -0
- package/dist/commonjs/v4/locales/zh-tw.js +154 -0
- package/dist/commonjs/v4/mini/checks.d.ts +1 -0
- package/dist/commonjs/v4/mini/checks.js +34 -0
- package/dist/commonjs/v4/mini/coerce.d.ts +7 -0
- package/dist/commonjs/v4/mini/coerce.js +57 -0
- package/dist/commonjs/v4/mini/external.d.ts +7 -0
- package/dist/commonjs/v4/mini/external.js +61 -0
- package/dist/commonjs/v4/mini/index.d.ts +3 -0
- package/dist/commonjs/v4/mini/index.js +42 -0
- package/dist/commonjs/v4/mini/iso.d.ts +22 -0
- package/dist/commonjs/v4/mini/iso.js +70 -0
- package/dist/commonjs/v4/mini/parse.d.ts +1 -0
- package/dist/commonjs/v4/mini/parse.js +8 -0
- package/dist/commonjs/v4/mini/schemas.d.ts +405 -0
- package/dist/commonjs/v4/mini/schemas.js +852 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/v3/ZodError.d.ts +164 -0
- package/dist/esm/v3/ZodError.js +132 -0
- package/dist/esm/v3/benchmarks/datetime.d.ts +5 -0
- package/dist/esm/v3/benchmarks/datetime.js +49 -0
- package/dist/esm/v3/benchmarks/discriminatedUnion.d.ts +5 -0
- package/dist/esm/v3/benchmarks/discriminatedUnion.js +74 -0
- package/dist/esm/v3/benchmarks/index.d.ts +1 -0
- package/dist/esm/v3/benchmarks/index.js +54 -0
- package/dist/esm/v3/benchmarks/ipv4.d.ts +5 -0
- package/dist/esm/v3/benchmarks/ipv4.js +49 -0
- package/dist/esm/v3/benchmarks/object.d.ts +5 -0
- package/dist/esm/v3/benchmarks/object.js +65 -0
- package/dist/esm/v3/benchmarks/primitives.d.ts +5 -0
- package/dist/esm/v3/benchmarks/primitives.js +154 -0
- package/dist/esm/v3/benchmarks/realworld.d.ts +5 -0
- package/dist/esm/v3/benchmarks/realworld.js +51 -0
- package/dist/esm/v3/benchmarks/string.d.ts +5 -0
- package/dist/esm/v3/benchmarks/string.js +50 -0
- package/dist/esm/v3/benchmarks/union.d.ts +5 -0
- package/dist/esm/v3/benchmarks/union.js +74 -0
- package/dist/esm/v3/errors.d.ts +5 -0
- package/dist/esm/v3/errors.js +9 -0
- package/dist/esm/v3/external.d.ts +6 -0
- package/dist/esm/v3/external.js +6 -0
- package/dist/esm/v3/helpers/enumUtil.d.ts +8 -0
- package/dist/esm/v3/helpers/enumUtil.js +1 -0
- package/dist/esm/v3/helpers/errorUtil.d.ts +9 -0
- package/dist/esm/v3/helpers/errorUtil.js +6 -0
- package/dist/esm/v3/helpers/parseUtil.d.ts +78 -0
- package/dist/esm/v3/helpers/parseUtil.js +109 -0
- package/dist/esm/v3/helpers/partialUtil.d.ts +8 -0
- package/dist/esm/v3/helpers/partialUtil.js +1 -0
- package/dist/esm/v3/helpers/typeAliases.d.ts +2 -0
- package/dist/esm/v3/helpers/typeAliases.js +1 -0
- package/dist/esm/v3/helpers/util.d.ts +85 -0
- package/dist/esm/v3/helpers/util.js +133 -0
- package/dist/esm/v3/index.d.ts +4 -0
- package/dist/esm/v3/index.js +4 -0
- package/dist/esm/v3/locales/en.d.ts +3 -0
- package/dist/esm/v3/locales/en.js +107 -0
- package/dist/esm/v3/standard-schema.d.ts +102 -0
- package/dist/esm/v3/standard-schema.js +1 -0
- package/dist/esm/v3/tests/Mocker.d.ts +17 -0
- package/dist/esm/v3/tests/Mocker.js +53 -0
- package/dist/esm/v3/tests/language-server.source.d.ts +70 -0
- package/dist/esm/v3/tests/language-server.source.js +45 -0
- package/dist/esm/v3/types.d.ts +1031 -0
- package/dist/esm/v3/types.js +3713 -0
- package/dist/esm/v4/classic/checks.d.ts +1 -0
- package/dist/esm/v4/classic/checks.js +1 -0
- package/dist/esm/v4/classic/coerce.d.ts +17 -0
- package/dist/esm/v4/classic/coerce.js +17 -0
- package/dist/esm/v4/classic/compat.d.ts +48 -0
- package/dist/esm/v4/classic/compat.js +33 -0
- package/dist/esm/v4/classic/errors.d.ts +30 -0
- package/dist/esm/v4/classic/errors.js +40 -0
- package/dist/esm/v4/classic/external.d.ts +8 -0
- package/dist/esm/v4/classic/external.js +11 -0
- package/dist/esm/v4/classic/index.d.ts +4 -0
- package/dist/esm/v4/classic/index.js +4 -0
- package/dist/esm/v4/classic/iso.d.ts +22 -0
- package/dist/esm/v4/classic/iso.js +30 -0
- package/dist/esm/v4/classic/parse.d.ts +23 -0
- package/dist/esm/v4/classic/parse.js +6 -0
- package/dist/esm/v4/classic/schemas.d.ts +653 -0
- package/dist/esm/v4/classic/schemas.js +1012 -0
- package/dist/esm/v4/core/api.d.ts +273 -0
- package/dist/esm/v4/core/api.js +867 -0
- package/dist/esm/v4/core/checks.d.ts +277 -0
- package/dist/esm/v4/core/checks.js +535 -0
- package/dist/esm/v4/core/config.d.ts +9 -0
- package/dist/esm/v4/core/config.js +6 -0
- package/dist/esm/v4/core/core.d.ts +43 -0
- package/dist/esm/v4/core/core.js +53 -0
- package/dist/esm/v4/core/doc.d.ts +14 -0
- package/dist/esm/v4/core/doc.js +36 -0
- package/dist/esm/v4/core/errors.d.ts +204 -0
- package/dist/esm/v4/core/errors.js +195 -0
- package/dist/esm/v4/core/function.d.ts +35 -0
- package/dist/esm/v4/core/function.js +70 -0
- package/dist/esm/v4/core/index.d.ts +15 -0
- package/dist/esm/v4/core/index.js +15 -0
- package/dist/esm/v4/core/json-schema.d.ts +100 -0
- package/dist/esm/v4/core/json-schema.js +1 -0
- package/dist/esm/v4/core/parse.d.ts +25 -0
- package/dist/esm/v4/core/parse.js +57 -0
- package/dist/esm/v4/core/regexes.d.ts +62 -0
- package/dist/esm/v4/core/regexes.js +93 -0
- package/dist/esm/v4/core/registries.d.ts +32 -0
- package/dist/esm/v4/core/registries.js +42 -0
- package/dist/esm/v4/core/schemas.d.ts +975 -0
- package/dist/esm/v4/core/schemas.js +1740 -0
- package/dist/esm/v4/core/standard-schema.d.ts +55 -0
- package/dist/esm/v4/core/standard-schema.js +1 -0
- package/dist/esm/v4/core/to-json-schema.d.ts +84 -0
- package/dist/esm/v4/core/to-json-schema.js +665 -0
- package/dist/esm/v4/core/util.d.ts +186 -0
- package/dist/esm/v4/core/util.js +469 -0
- package/dist/esm/v4/core/versions.d.ts +5 -0
- package/dist/esm/v4/core/versions.js +5 -0
- package/dist/esm/v4/core/zsf.d.ts +91 -0
- package/dist/esm/v4/core/zsf.js +171 -0
- package/dist/esm/v4/index.d.ts +3 -0
- package/dist/esm/v4/index.js +3 -0
- package/dist/esm/v4/locales/ar.d.ts +7 -0
- package/dist/esm/v4/locales/ar.js +115 -0
- package/dist/esm/v4/locales/az.d.ts +7 -0
- package/dist/esm/v4/locales/az.js +114 -0
- package/dist/esm/v4/locales/be.d.ts +7 -0
- package/dist/esm/v4/locales/be.js +163 -0
- package/dist/esm/v4/locales/ca.d.ts +7 -0
- package/dist/esm/v4/locales/ca.js +117 -0
- package/dist/esm/v4/locales/cs.d.ts +7 -0
- package/dist/esm/v4/locales/cs.js +134 -0
- package/dist/esm/v4/locales/de.d.ts +7 -0
- package/dist/esm/v4/locales/de.js +115 -0
- package/dist/esm/v4/locales/en.d.ts +7 -0
- package/dist/esm/v4/locales/en.js +117 -0
- package/dist/esm/v4/locales/es.d.ts +7 -0
- package/dist/esm/v4/locales/es.js +116 -0
- package/dist/esm/v4/locales/fa.d.ts +7 -0
- package/dist/esm/v4/locales/fa.js +121 -0
- package/dist/esm/v4/locales/fi.d.ts +7 -0
- package/dist/esm/v4/locales/fi.js +121 -0
- package/dist/esm/v4/locales/fr.d.ts +7 -0
- package/dist/esm/v4/locales/fr.js +115 -0
- package/dist/esm/v4/locales/frCA.d.ts +7 -0
- package/dist/esm/v4/locales/frCA.js +116 -0
- package/dist/esm/v4/locales/he.d.ts +7 -0
- package/dist/esm/v4/locales/he.js +116 -0
- package/dist/esm/v4/locales/hu.d.ts +7 -0
- package/dist/esm/v4/locales/hu.js +116 -0
- package/dist/esm/v4/locales/id.d.ts +7 -0
- package/dist/esm/v4/locales/id.js +115 -0
- package/dist/esm/v4/locales/index.d.ts +34 -0
- package/dist/esm/v4/locales/index.js +34 -0
- package/dist/esm/v4/locales/it.d.ts +7 -0
- package/dist/esm/v4/locales/it.js +116 -0
- package/dist/esm/v4/locales/ja.d.ts +7 -0
- package/dist/esm/v4/locales/ja.js +114 -0
- package/dist/esm/v4/locales/ko.d.ts +7 -0
- package/dist/esm/v4/locales/ko.js +120 -0
- package/dist/esm/v4/locales/mk.d.ts +7 -0
- package/dist/esm/v4/locales/mk.js +117 -0
- package/dist/esm/v4/locales/ms.d.ts +7 -0
- package/dist/esm/v4/locales/ms.js +115 -0
- package/dist/esm/v4/locales/no.d.ts +7 -0
- package/dist/esm/v4/locales/no.js +115 -0
- package/dist/esm/v4/locales/ota.d.ts +7 -0
- package/dist/esm/v4/locales/ota.js +116 -0
- package/dist/esm/v4/locales/pl.d.ts +7 -0
- package/dist/esm/v4/locales/pl.js +116 -0
- package/dist/esm/v4/locales/pt.d.ts +7 -0
- package/dist/esm/v4/locales/pt.js +115 -0
- package/dist/esm/v4/locales/ru.d.ts +7 -0
- package/dist/esm/v4/locales/ru.js +163 -0
- package/dist/esm/v4/locales/sl.d.ts +7 -0
- package/dist/esm/v4/locales/sl.js +116 -0
- package/dist/esm/v4/locales/ta.d.ts +7 -0
- package/dist/esm/v4/locales/ta.js +116 -0
- package/dist/esm/v4/locales/th.d.ts +7 -0
- package/dist/esm/v4/locales/th.js +116 -0
- package/dist/esm/v4/locales/tr.d.ts +7 -0
- package/dist/esm/v4/locales/tr.js +114 -0
- package/dist/esm/v4/locales/ua.d.ts +7 -0
- package/dist/esm/v4/locales/ua.js +116 -0
- package/dist/esm/v4/locales/ur.d.ts +7 -0
- package/dist/esm/v4/locales/ur.js +116 -0
- package/dist/esm/v4/locales/vi.d.ts +7 -0
- package/dist/esm/v4/locales/vi.js +115 -0
- package/dist/esm/v4/locales/zh-CN.d.ts +7 -0
- package/dist/esm/v4/locales/zh-CN.js +115 -0
- package/dist/esm/v4/locales/zh-tw.d.ts +7 -0
- package/dist/esm/v4/locales/zh-tw.js +116 -0
- package/dist/esm/v4/mini/checks.d.ts +1 -0
- package/dist/esm/v4/mini/checks.js +1 -0
- package/dist/esm/v4/mini/coerce.d.ts +7 -0
- package/dist/esm/v4/mini/coerce.js +17 -0
- package/dist/esm/v4/mini/external.d.ts +7 -0
- package/dist/esm/v4/mini/external.js +7 -0
- package/dist/esm/v4/mini/index.d.ts +3 -0
- package/dist/esm/v4/mini/index.js +3 -0
- package/dist/esm/v4/mini/iso.d.ts +22 -0
- package/dist/esm/v4/mini/iso.js +30 -0
- package/dist/esm/v4/mini/parse.d.ts +1 -0
- package/dist/esm/v4/mini/parse.js +1 -0
- package/dist/esm/v4/mini/schemas.d.ts +405 -0
- package/dist/esm/v4/mini/schemas.js +738 -0
- package/package.json +1 -1
- package/src/v4/core/schemas.ts +0 -2
- package/src/v4/core/to-json-schema.ts +1 -1
|
@@ -0,0 +1,535 @@
|
|
|
1
|
+
// import { $ZodType } from "./schemas.js";
|
|
2
|
+
import * as core from "./core.js";
|
|
3
|
+
import * as regexes from "./regexes.js";
|
|
4
|
+
import * as util from "./util.js";
|
|
5
|
+
export const $ZodCheck = /*@__PURE__*/ core.$constructor("$ZodCheck", (inst, def) => {
|
|
6
|
+
var _a;
|
|
7
|
+
inst._zod ?? (inst._zod = {});
|
|
8
|
+
inst._zod.def = def;
|
|
9
|
+
(_a = inst._zod).onattach ?? (_a.onattach = []);
|
|
10
|
+
});
|
|
11
|
+
const numericOriginMap = {
|
|
12
|
+
number: "number",
|
|
13
|
+
bigint: "bigint",
|
|
14
|
+
object: "date",
|
|
15
|
+
};
|
|
16
|
+
export const $ZodCheckLessThan = /*@__PURE__*/ core.$constructor("$ZodCheckLessThan", (inst, def) => {
|
|
17
|
+
$ZodCheck.init(inst, def);
|
|
18
|
+
const origin = numericOriginMap[typeof def.value];
|
|
19
|
+
inst._zod.onattach.push((inst) => {
|
|
20
|
+
const bag = inst._zod.bag;
|
|
21
|
+
const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
|
|
22
|
+
if (def.value < curr) {
|
|
23
|
+
if (def.inclusive)
|
|
24
|
+
bag.maximum = def.value;
|
|
25
|
+
else
|
|
26
|
+
bag.exclusiveMaximum = def.value;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
inst._zod.check = (payload) => {
|
|
30
|
+
if (def.inclusive ? payload.value <= def.value : payload.value < def.value) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
payload.issues.push({
|
|
34
|
+
origin,
|
|
35
|
+
code: "too_big",
|
|
36
|
+
maximum: def.value,
|
|
37
|
+
input: payload.value,
|
|
38
|
+
inclusive: def.inclusive,
|
|
39
|
+
inst,
|
|
40
|
+
continue: !def.abort,
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
export const $ZodCheckGreaterThan = /*@__PURE__*/ core.$constructor("$ZodCheckGreaterThan", (inst, def) => {
|
|
45
|
+
$ZodCheck.init(inst, def);
|
|
46
|
+
const origin = numericOriginMap[typeof def.value];
|
|
47
|
+
inst._zod.onattach.push((inst) => {
|
|
48
|
+
const bag = inst._zod.bag;
|
|
49
|
+
const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
|
|
50
|
+
if (def.value > curr) {
|
|
51
|
+
if (def.inclusive)
|
|
52
|
+
bag.minimum = def.value;
|
|
53
|
+
else
|
|
54
|
+
bag.exclusiveMinimum = def.value;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
inst._zod.check = (payload) => {
|
|
58
|
+
if (def.inclusive ? payload.value >= def.value : payload.value > def.value) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
payload.issues.push({
|
|
62
|
+
origin: origin,
|
|
63
|
+
code: "too_small",
|
|
64
|
+
minimum: def.value,
|
|
65
|
+
input: payload.value,
|
|
66
|
+
inclusive: def.inclusive,
|
|
67
|
+
inst,
|
|
68
|
+
continue: !def.abort,
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
export const $ZodCheckMultipleOf =
|
|
73
|
+
/*@__PURE__*/ core.$constructor("$ZodCheckMultipleOf", (inst, def) => {
|
|
74
|
+
$ZodCheck.init(inst, def);
|
|
75
|
+
inst._zod.onattach.push((inst) => {
|
|
76
|
+
var _a;
|
|
77
|
+
(_a = inst._zod.bag).multipleOf ?? (_a.multipleOf = def.value);
|
|
78
|
+
});
|
|
79
|
+
inst._zod.check = (payload) => {
|
|
80
|
+
if (typeof payload.value !== typeof def.value)
|
|
81
|
+
throw new Error("Cannot mix number and bigint in multiple_of check.");
|
|
82
|
+
const isMultiple = typeof payload.value === "bigint"
|
|
83
|
+
? payload.value % def.value === BigInt(0)
|
|
84
|
+
: util.floatSafeRemainder(payload.value, def.value) === 0;
|
|
85
|
+
if (isMultiple)
|
|
86
|
+
return;
|
|
87
|
+
payload.issues.push({
|
|
88
|
+
origin: typeof payload.value,
|
|
89
|
+
code: "not_multiple_of",
|
|
90
|
+
divisor: def.value,
|
|
91
|
+
input: payload.value,
|
|
92
|
+
inst,
|
|
93
|
+
continue: !def.abort,
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
});
|
|
97
|
+
export const $ZodCheckNumberFormat = /*@__PURE__*/ core.$constructor("$ZodCheckNumberFormat", (inst, def) => {
|
|
98
|
+
$ZodCheck.init(inst, def); // no format checks
|
|
99
|
+
def.format = def.format || "float64";
|
|
100
|
+
const isInt = def.format?.includes("int");
|
|
101
|
+
const origin = isInt ? "int" : "number";
|
|
102
|
+
const [minimum, maximum] = util.NUMBER_FORMAT_RANGES[def.format];
|
|
103
|
+
inst._zod.onattach.push((inst) => {
|
|
104
|
+
const bag = inst._zod.bag;
|
|
105
|
+
bag.format = def.format;
|
|
106
|
+
bag.minimum = minimum;
|
|
107
|
+
bag.maximum = maximum;
|
|
108
|
+
if (isInt)
|
|
109
|
+
bag.pattern = regexes.integer;
|
|
110
|
+
});
|
|
111
|
+
inst._zod.check = (payload) => {
|
|
112
|
+
const input = payload.value;
|
|
113
|
+
if (isInt) {
|
|
114
|
+
if (!Number.isInteger(input)) {
|
|
115
|
+
// invalid_type issue
|
|
116
|
+
payload.issues.push({
|
|
117
|
+
expected: origin,
|
|
118
|
+
format: def.format,
|
|
119
|
+
code: "invalid_type",
|
|
120
|
+
input,
|
|
121
|
+
inst,
|
|
122
|
+
});
|
|
123
|
+
return;
|
|
124
|
+
// not_multiple_of issue
|
|
125
|
+
// payload.issues.push({
|
|
126
|
+
// code: "not_multiple_of",
|
|
127
|
+
// origin: "number",
|
|
128
|
+
// input,
|
|
129
|
+
// inst,
|
|
130
|
+
// divisor: 1,
|
|
131
|
+
// });
|
|
132
|
+
}
|
|
133
|
+
if (!Number.isSafeInteger(input)) {
|
|
134
|
+
if (input > 0) {
|
|
135
|
+
// too_big
|
|
136
|
+
payload.issues.push({
|
|
137
|
+
input,
|
|
138
|
+
code: "too_big",
|
|
139
|
+
maximum: Number.MAX_SAFE_INTEGER,
|
|
140
|
+
note: "Integers must be within the the safe integer range.",
|
|
141
|
+
inst,
|
|
142
|
+
origin,
|
|
143
|
+
continue: !def.abort,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
// too_small
|
|
148
|
+
payload.issues.push({
|
|
149
|
+
input,
|
|
150
|
+
code: "too_small",
|
|
151
|
+
minimum: Number.MIN_SAFE_INTEGER,
|
|
152
|
+
note: "Integers must be within the safe integer range.",
|
|
153
|
+
inst,
|
|
154
|
+
origin,
|
|
155
|
+
continue: !def.abort,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (input < minimum) {
|
|
162
|
+
payload.issues.push({
|
|
163
|
+
origin: "number",
|
|
164
|
+
input: input,
|
|
165
|
+
code: "too_small",
|
|
166
|
+
minimum: minimum,
|
|
167
|
+
inclusive: true,
|
|
168
|
+
inst,
|
|
169
|
+
continue: !def.abort,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
if (input > maximum) {
|
|
173
|
+
payload.issues.push({
|
|
174
|
+
origin: "number",
|
|
175
|
+
input,
|
|
176
|
+
code: "too_big",
|
|
177
|
+
maximum,
|
|
178
|
+
inst,
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
});
|
|
183
|
+
export const $ZodCheckBigIntFormat = /*@__PURE__*/ core.$constructor("$ZodCheckBigIntFormat", (inst, def) => {
|
|
184
|
+
$ZodCheck.init(inst, def); // no format checks
|
|
185
|
+
const [minimum, maximum] = util.BIGINT_FORMAT_RANGES[def.format];
|
|
186
|
+
inst._zod.onattach.push((inst) => {
|
|
187
|
+
const bag = inst._zod.bag;
|
|
188
|
+
bag.format = def.format;
|
|
189
|
+
bag.minimum = minimum;
|
|
190
|
+
bag.maximum = maximum;
|
|
191
|
+
});
|
|
192
|
+
inst._zod.check = (payload) => {
|
|
193
|
+
const input = payload.value;
|
|
194
|
+
if (input < minimum) {
|
|
195
|
+
payload.issues.push({
|
|
196
|
+
origin: "bigint",
|
|
197
|
+
input,
|
|
198
|
+
code: "too_small",
|
|
199
|
+
minimum: minimum,
|
|
200
|
+
inclusive: true,
|
|
201
|
+
inst,
|
|
202
|
+
continue: !def.abort,
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
if (input > maximum) {
|
|
206
|
+
payload.issues.push({
|
|
207
|
+
origin: "bigint",
|
|
208
|
+
input,
|
|
209
|
+
code: "too_big",
|
|
210
|
+
maximum,
|
|
211
|
+
inst,
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
});
|
|
216
|
+
export const $ZodCheckMaxSize = /*@__PURE__*/ core.$constructor("$ZodCheckMaxSize", (inst, def) => {
|
|
217
|
+
$ZodCheck.init(inst, def);
|
|
218
|
+
inst._zod.when = (payload) => {
|
|
219
|
+
const val = payload.value;
|
|
220
|
+
return !util.nullish(val) && val.size !== undefined;
|
|
221
|
+
};
|
|
222
|
+
inst._zod.onattach.push((inst) => {
|
|
223
|
+
const curr = (inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY);
|
|
224
|
+
if (def.maximum < curr)
|
|
225
|
+
inst._zod.bag.maximum = def.maximum;
|
|
226
|
+
});
|
|
227
|
+
inst._zod.check = (payload) => {
|
|
228
|
+
const input = payload.value;
|
|
229
|
+
const size = input.size;
|
|
230
|
+
if (size <= def.maximum)
|
|
231
|
+
return;
|
|
232
|
+
payload.issues.push({
|
|
233
|
+
origin: util.getSizableOrigin(input),
|
|
234
|
+
code: "too_big",
|
|
235
|
+
maximum: def.maximum,
|
|
236
|
+
input,
|
|
237
|
+
inst,
|
|
238
|
+
continue: !def.abort,
|
|
239
|
+
});
|
|
240
|
+
};
|
|
241
|
+
});
|
|
242
|
+
export const $ZodCheckMinSize = /*@__PURE__*/ core.$constructor("$ZodCheckMinSize", (inst, def) => {
|
|
243
|
+
$ZodCheck.init(inst, def);
|
|
244
|
+
inst._zod.when = (payload) => {
|
|
245
|
+
const val = payload.value;
|
|
246
|
+
return !util.nullish(val) && val.size !== undefined;
|
|
247
|
+
};
|
|
248
|
+
inst._zod.onattach.push((inst) => {
|
|
249
|
+
const curr = (inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY);
|
|
250
|
+
if (def.minimum > curr)
|
|
251
|
+
inst._zod.bag.minimum = def.minimum;
|
|
252
|
+
});
|
|
253
|
+
inst._zod.check = (payload) => {
|
|
254
|
+
const input = payload.value;
|
|
255
|
+
const size = input.size;
|
|
256
|
+
if (size >= def.minimum)
|
|
257
|
+
return;
|
|
258
|
+
payload.issues.push({
|
|
259
|
+
origin: util.getSizableOrigin(input),
|
|
260
|
+
code: "too_small",
|
|
261
|
+
minimum: def.minimum,
|
|
262
|
+
input,
|
|
263
|
+
inst,
|
|
264
|
+
continue: !def.abort,
|
|
265
|
+
});
|
|
266
|
+
};
|
|
267
|
+
});
|
|
268
|
+
export const $ZodCheckSizeEquals = /*@__PURE__*/ core.$constructor("$ZodCheckSizeEquals", (inst, def) => {
|
|
269
|
+
$ZodCheck.init(inst, def);
|
|
270
|
+
inst._zod.when = (payload) => {
|
|
271
|
+
const val = payload.value;
|
|
272
|
+
return !util.nullish(val) && val.size !== undefined;
|
|
273
|
+
};
|
|
274
|
+
inst._zod.onattach.push((inst) => {
|
|
275
|
+
const bag = inst._zod.bag;
|
|
276
|
+
bag.minimum = def.size;
|
|
277
|
+
bag.maximum = def.size;
|
|
278
|
+
bag.size = def.size;
|
|
279
|
+
});
|
|
280
|
+
inst._zod.check = (payload) => {
|
|
281
|
+
const input = payload.value;
|
|
282
|
+
const size = input.size;
|
|
283
|
+
if (size === def.size)
|
|
284
|
+
return;
|
|
285
|
+
const tooBig = size > def.size;
|
|
286
|
+
payload.issues.push({
|
|
287
|
+
origin: util.getSizableOrigin(input),
|
|
288
|
+
...(tooBig ? { code: "too_big", maximum: def.size } : { code: "too_small", minimum: def.size }),
|
|
289
|
+
input: payload.value,
|
|
290
|
+
inst,
|
|
291
|
+
continue: !def.abort,
|
|
292
|
+
});
|
|
293
|
+
};
|
|
294
|
+
});
|
|
295
|
+
export const $ZodCheckMaxLength = /*@__PURE__*/ core.$constructor("$ZodCheckMaxLength", (inst, def) => {
|
|
296
|
+
$ZodCheck.init(inst, def);
|
|
297
|
+
inst._zod.when = (payload) => {
|
|
298
|
+
const val = payload.value;
|
|
299
|
+
return !util.nullish(val) && val.length !== undefined;
|
|
300
|
+
};
|
|
301
|
+
inst._zod.onattach.push((inst) => {
|
|
302
|
+
const curr = (inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY);
|
|
303
|
+
if (def.maximum < curr)
|
|
304
|
+
inst._zod.bag.maximum = def.maximum;
|
|
305
|
+
});
|
|
306
|
+
inst._zod.check = (payload) => {
|
|
307
|
+
const input = payload.value;
|
|
308
|
+
const length = input.length;
|
|
309
|
+
if (length <= def.maximum)
|
|
310
|
+
return;
|
|
311
|
+
const origin = util.getLengthableOrigin(input);
|
|
312
|
+
payload.issues.push({
|
|
313
|
+
origin,
|
|
314
|
+
code: "too_big",
|
|
315
|
+
maximum: def.maximum,
|
|
316
|
+
input,
|
|
317
|
+
inst,
|
|
318
|
+
continue: !def.abort,
|
|
319
|
+
});
|
|
320
|
+
};
|
|
321
|
+
});
|
|
322
|
+
export const $ZodCheckMinLength = /*@__PURE__*/ core.$constructor("$ZodCheckMinLength", (inst, def) => {
|
|
323
|
+
$ZodCheck.init(inst, def);
|
|
324
|
+
inst._zod.when = (payload) => {
|
|
325
|
+
const val = payload.value;
|
|
326
|
+
return !util.nullish(val) && val.length !== undefined;
|
|
327
|
+
};
|
|
328
|
+
inst._zod.onattach.push((inst) => {
|
|
329
|
+
const curr = (inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY);
|
|
330
|
+
if (def.minimum > curr)
|
|
331
|
+
inst._zod.bag.minimum = def.minimum;
|
|
332
|
+
});
|
|
333
|
+
inst._zod.check = (payload) => {
|
|
334
|
+
const input = payload.value;
|
|
335
|
+
const length = input.length;
|
|
336
|
+
if (length >= def.minimum)
|
|
337
|
+
return;
|
|
338
|
+
const origin = util.getLengthableOrigin(input);
|
|
339
|
+
payload.issues.push({
|
|
340
|
+
origin,
|
|
341
|
+
code: "too_small",
|
|
342
|
+
minimum: def.minimum,
|
|
343
|
+
input,
|
|
344
|
+
inst,
|
|
345
|
+
continue: !def.abort,
|
|
346
|
+
});
|
|
347
|
+
};
|
|
348
|
+
});
|
|
349
|
+
export const $ZodCheckLengthEquals = /*@__PURE__*/ core.$constructor("$ZodCheckLengthEquals", (inst, def) => {
|
|
350
|
+
$ZodCheck.init(inst, def);
|
|
351
|
+
inst._zod.when = (payload) => {
|
|
352
|
+
const val = payload.value;
|
|
353
|
+
return !util.nullish(val) && val.length !== undefined;
|
|
354
|
+
};
|
|
355
|
+
inst._zod.onattach.push((inst) => {
|
|
356
|
+
const bag = inst._zod.bag;
|
|
357
|
+
bag.minimum = def.length;
|
|
358
|
+
bag.maximum = def.length;
|
|
359
|
+
bag.length = def.length;
|
|
360
|
+
});
|
|
361
|
+
inst._zod.check = (payload) => {
|
|
362
|
+
const input = payload.value;
|
|
363
|
+
const length = input.length;
|
|
364
|
+
if (length === def.length)
|
|
365
|
+
return;
|
|
366
|
+
const origin = util.getLengthableOrigin(input);
|
|
367
|
+
const tooBig = length > def.length;
|
|
368
|
+
payload.issues.push({
|
|
369
|
+
origin,
|
|
370
|
+
...(tooBig ? { code: "too_big", maximum: def.length } : { code: "too_small", minimum: def.length }),
|
|
371
|
+
input: payload.value,
|
|
372
|
+
inst,
|
|
373
|
+
continue: !def.abort,
|
|
374
|
+
});
|
|
375
|
+
};
|
|
376
|
+
});
|
|
377
|
+
export const $ZodCheckStringFormat = /*@__PURE__*/ core.$constructor("$ZodCheckStringFormat", (inst, def) => {
|
|
378
|
+
var _a;
|
|
379
|
+
$ZodCheck.init(inst, def);
|
|
380
|
+
inst._zod.onattach.push((inst) => {
|
|
381
|
+
inst._zod.bag.format = def.format;
|
|
382
|
+
if (def.pattern)
|
|
383
|
+
inst._zod.bag.pattern = def.pattern;
|
|
384
|
+
});
|
|
385
|
+
(_a = inst._zod).check ?? (_a.check = (payload) => {
|
|
386
|
+
if (!def.pattern)
|
|
387
|
+
throw new Error("Not implemented.");
|
|
388
|
+
def.pattern.lastIndex = 0;
|
|
389
|
+
if (def.pattern.test(payload.value))
|
|
390
|
+
return;
|
|
391
|
+
payload.issues.push({
|
|
392
|
+
origin: "string",
|
|
393
|
+
code: "invalid_format",
|
|
394
|
+
format: def.format,
|
|
395
|
+
input: payload.value,
|
|
396
|
+
...(def.pattern ? { pattern: def.pattern.toString() } : {}),
|
|
397
|
+
inst,
|
|
398
|
+
continue: !def.abort,
|
|
399
|
+
});
|
|
400
|
+
});
|
|
401
|
+
});
|
|
402
|
+
export const $ZodCheckRegex = /*@__PURE__*/ core.$constructor("$ZodCheckRegex", (inst, def) => {
|
|
403
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
404
|
+
inst._zod.check = (payload) => {
|
|
405
|
+
def.pattern.lastIndex = 0;
|
|
406
|
+
if (def.pattern.test(payload.value))
|
|
407
|
+
return;
|
|
408
|
+
payload.issues.push({
|
|
409
|
+
origin: "string",
|
|
410
|
+
code: "invalid_format",
|
|
411
|
+
format: "regex",
|
|
412
|
+
input: payload.value,
|
|
413
|
+
pattern: def.pattern.toString(),
|
|
414
|
+
inst,
|
|
415
|
+
continue: !def.abort,
|
|
416
|
+
});
|
|
417
|
+
};
|
|
418
|
+
});
|
|
419
|
+
export const $ZodCheckLowerCase = /*@__PURE__*/ core.$constructor("$ZodCheckLowerCase", (inst, def) => {
|
|
420
|
+
def.pattern ?? (def.pattern = regexes.lowercase);
|
|
421
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
422
|
+
});
|
|
423
|
+
export const $ZodCheckUpperCase = /*@__PURE__*/ core.$constructor("$ZodCheckUpperCase", (inst, def) => {
|
|
424
|
+
def.pattern ?? (def.pattern = regexes.uppercase);
|
|
425
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
426
|
+
});
|
|
427
|
+
export const $ZodCheckIncludes = /*@__PURE__*/ core.$constructor("$ZodCheckIncludes", (inst, def) => {
|
|
428
|
+
$ZodCheck.init(inst, def);
|
|
429
|
+
const pattern = new RegExp(util.escapeRegex(def.includes));
|
|
430
|
+
def.pattern = pattern;
|
|
431
|
+
inst._zod.onattach.push((inst) => {
|
|
432
|
+
inst._zod.bag.pattern = pattern;
|
|
433
|
+
});
|
|
434
|
+
inst._zod.check = (payload) => {
|
|
435
|
+
if (payload.value.includes(def.includes, def.position))
|
|
436
|
+
return;
|
|
437
|
+
payload.issues.push({
|
|
438
|
+
origin: "string",
|
|
439
|
+
code: "invalid_format",
|
|
440
|
+
format: "includes",
|
|
441
|
+
includes: def.includes,
|
|
442
|
+
input: payload.value,
|
|
443
|
+
inst,
|
|
444
|
+
continue: !def.abort,
|
|
445
|
+
});
|
|
446
|
+
};
|
|
447
|
+
});
|
|
448
|
+
export const $ZodCheckStartsWith = /*@__PURE__*/ core.$constructor("$ZodCheckStartsWith", (inst, def) => {
|
|
449
|
+
$ZodCheck.init(inst, def);
|
|
450
|
+
const pattern = new RegExp(`^${util.escapeRegex(def.prefix)}.*`);
|
|
451
|
+
def.pattern ?? (def.pattern = pattern);
|
|
452
|
+
inst._zod.onattach.push((inst) => {
|
|
453
|
+
inst._zod.bag.pattern = pattern;
|
|
454
|
+
});
|
|
455
|
+
inst._zod.check = (payload) => {
|
|
456
|
+
if (payload.value.startsWith(def.prefix))
|
|
457
|
+
return;
|
|
458
|
+
payload.issues.push({
|
|
459
|
+
origin: "string",
|
|
460
|
+
code: "invalid_format",
|
|
461
|
+
format: "starts_with",
|
|
462
|
+
prefix: def.prefix,
|
|
463
|
+
input: payload.value,
|
|
464
|
+
inst,
|
|
465
|
+
continue: !def.abort,
|
|
466
|
+
});
|
|
467
|
+
};
|
|
468
|
+
});
|
|
469
|
+
export const $ZodCheckEndsWith = /*@__PURE__*/ core.$constructor("$ZodCheckEndsWith", (inst, def) => {
|
|
470
|
+
$ZodCheck.init(inst, def);
|
|
471
|
+
const pattern = new RegExp(`.*${util.escapeRegex(def.suffix)}$`);
|
|
472
|
+
def.pattern ?? (def.pattern = pattern);
|
|
473
|
+
inst._zod.onattach.push((inst) => {
|
|
474
|
+
inst._zod.bag.pattern = new RegExp(`.*${util.escapeRegex(def.suffix)}$`);
|
|
475
|
+
});
|
|
476
|
+
inst._zod.check = (payload) => {
|
|
477
|
+
if (payload.value.endsWith(def.suffix))
|
|
478
|
+
return;
|
|
479
|
+
payload.issues.push({
|
|
480
|
+
origin: "string",
|
|
481
|
+
code: "invalid_format",
|
|
482
|
+
format: "ends_with",
|
|
483
|
+
suffix: def.suffix,
|
|
484
|
+
input: payload.value,
|
|
485
|
+
inst,
|
|
486
|
+
continue: !def.abort,
|
|
487
|
+
});
|
|
488
|
+
};
|
|
489
|
+
});
|
|
490
|
+
///////////////////////////////////
|
|
491
|
+
///// $ZodCheckProperty /////
|
|
492
|
+
///////////////////////////////////
|
|
493
|
+
function handleCheckPropertyResult(result, payload, property) {
|
|
494
|
+
if (result.issues.length) {
|
|
495
|
+
payload.issues.push(...util.prefixIssues(property, result.issues));
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
export const $ZodCheckProperty = /*@__PURE__*/ core.$constructor("$ZodCheckProperty", (inst, def) => {
|
|
499
|
+
$ZodCheck.init(inst, def);
|
|
500
|
+
inst._zod.check = (payload) => {
|
|
501
|
+
const result = def.schema._zod.run({
|
|
502
|
+
value: payload.value[def.property],
|
|
503
|
+
issues: [],
|
|
504
|
+
}, {});
|
|
505
|
+
if (result instanceof Promise) {
|
|
506
|
+
return result.then((result) => handleCheckPropertyResult(result, payload, def.property));
|
|
507
|
+
}
|
|
508
|
+
handleCheckPropertyResult(result, payload, def.property);
|
|
509
|
+
return;
|
|
510
|
+
};
|
|
511
|
+
});
|
|
512
|
+
export const $ZodCheckMimeType = /*@__PURE__*/ core.$constructor("$ZodCheckMimeType", (inst, def) => {
|
|
513
|
+
$ZodCheck.init(inst, def);
|
|
514
|
+
const mimeSet = new Set(def.mime);
|
|
515
|
+
inst._zod.onattach.push((inst) => {
|
|
516
|
+
inst._zod.bag.mime = def.mime;
|
|
517
|
+
});
|
|
518
|
+
inst._zod.check = (payload) => {
|
|
519
|
+
if (mimeSet.has(payload.value.type))
|
|
520
|
+
return;
|
|
521
|
+
payload.issues.push({
|
|
522
|
+
code: "invalid_value",
|
|
523
|
+
values: def.mime,
|
|
524
|
+
input: payload.value.type,
|
|
525
|
+
path: ["type"],
|
|
526
|
+
inst,
|
|
527
|
+
});
|
|
528
|
+
};
|
|
529
|
+
});
|
|
530
|
+
export const $ZodCheckOverwrite = /*@__PURE__*/ core.$constructor("$ZodCheckOverwrite", (inst, def) => {
|
|
531
|
+
$ZodCheck.init(inst, def);
|
|
532
|
+
inst._zod.check = (payload) => {
|
|
533
|
+
payload.value = def.tx(payload.value);
|
|
534
|
+
};
|
|
535
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type * as errors from "./errors.js";
|
|
2
|
+
export interface $ZodConfig {
|
|
3
|
+
/** Custom error map. Overrides `config().localeError`. */
|
|
4
|
+
customError?: errors.$ZodErrorMap | undefined;
|
|
5
|
+
/** Localized error map. Lowest priority. */
|
|
6
|
+
localeError?: errors.$ZodErrorMap | undefined;
|
|
7
|
+
}
|
|
8
|
+
export declare const globalConfig: $ZodConfig;
|
|
9
|
+
export declare function config(config?: Partial<$ZodConfig>): $ZodConfig;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type * as errors from "./errors.js";
|
|
2
|
+
import type * as schemas from "./schemas.js";
|
|
3
|
+
import type { Class } from "./util.js";
|
|
4
|
+
type ZodTrait = {
|
|
5
|
+
_zod: {
|
|
6
|
+
def: any;
|
|
7
|
+
[k: string]: any;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export interface $constructor<T extends ZodTrait, D = T["_zod"]["def"]> {
|
|
11
|
+
new (def: D): T;
|
|
12
|
+
init(inst: T, def: D): asserts inst is T;
|
|
13
|
+
}
|
|
14
|
+
export declare function $constructor<T extends ZodTrait, D = T["_zod"]["def"]>(name: string, initializer: (inst: T, def: D) => void, params?: {
|
|
15
|
+
Parent?: typeof Class;
|
|
16
|
+
}): $constructor<T, D>;
|
|
17
|
+
export declare const $brand: unique symbol;
|
|
18
|
+
export type $brand<T extends string | number | symbol = string | number | symbol> = {
|
|
19
|
+
[$brand]: {
|
|
20
|
+
[k in T]: true;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export type $ZodBranded<T extends schemas.$ZodType, Brand extends string | number | symbol> = T & Record<"_zod", Record<"~output", output<T> & $brand<Brand>>>;
|
|
24
|
+
export declare class $ZodAsyncError extends Error {
|
|
25
|
+
constructor();
|
|
26
|
+
}
|
|
27
|
+
export type input<T extends schemas.$ZodType> = T["_zod"] extends {
|
|
28
|
+
"~input": any;
|
|
29
|
+
} ? T["_zod"]["~input"] : T["_zod"]["input"];
|
|
30
|
+
export type output<T extends schemas.$ZodType> = T["_zod"] extends {
|
|
31
|
+
"~output": any;
|
|
32
|
+
} ? T["_zod"]["~output"] : T["_zod"]["output"];
|
|
33
|
+
export type { output as infer };
|
|
34
|
+
export interface $ZodConfig {
|
|
35
|
+
/** Custom error map. Overrides `config().localeError`. */
|
|
36
|
+
customError?: errors.$ZodErrorMap | undefined;
|
|
37
|
+
/** Localized error map. Lowest priority. */
|
|
38
|
+
localeError?: errors.$ZodErrorMap | undefined;
|
|
39
|
+
/** Disable JIT schema compilation. Useful in environments that disallow `eval`. */
|
|
40
|
+
jitless?: boolean | undefined;
|
|
41
|
+
}
|
|
42
|
+
export declare const globalConfig: $ZodConfig;
|
|
43
|
+
export declare function config(newConfig?: Partial<$ZodConfig>): $ZodConfig;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export /*@__NO_SIDE_EFFECTS__*/ function $constructor(name, initializer, params) {
|
|
2
|
+
const Parent = params?.Parent ?? Object;
|
|
3
|
+
class _ extends Parent {
|
|
4
|
+
constructor(def) {
|
|
5
|
+
var _a;
|
|
6
|
+
super();
|
|
7
|
+
const th = this;
|
|
8
|
+
_.init(th, def);
|
|
9
|
+
(_a = th._zod).deferred ?? (_a.deferred = []);
|
|
10
|
+
for (const fn of th._zod.deferred) {
|
|
11
|
+
fn();
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
static init(inst, def) {
|
|
15
|
+
var _a;
|
|
16
|
+
Object.defineProperty(inst, "_zod", {
|
|
17
|
+
value: inst._zod ?? {},
|
|
18
|
+
enumerable: false,
|
|
19
|
+
});
|
|
20
|
+
// inst._zod ??= {} as any;
|
|
21
|
+
(_a = inst._zod).traits ?? (_a.traits = new Set());
|
|
22
|
+
// const seen = inst._zod.traits.has(name);
|
|
23
|
+
inst._zod.traits.add(name);
|
|
24
|
+
initializer(inst, def);
|
|
25
|
+
// support prototype modifications
|
|
26
|
+
for (const k in _.prototype) {
|
|
27
|
+
Object.defineProperty(inst, k, { value: _.prototype[k].bind(inst) });
|
|
28
|
+
}
|
|
29
|
+
inst._zod.constr = _;
|
|
30
|
+
inst._zod.def = def;
|
|
31
|
+
}
|
|
32
|
+
static [Symbol.hasInstance](inst) {
|
|
33
|
+
if (params?.Parent && inst instanceof params.Parent)
|
|
34
|
+
return true;
|
|
35
|
+
return inst?._zod?.traits?.has(name);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
Object.defineProperty(_, "name", { value: name });
|
|
39
|
+
return _;
|
|
40
|
+
}
|
|
41
|
+
////////////////////////////// UTILITIES ///////////////////////////////////////
|
|
42
|
+
export const $brand = Symbol("zod_brand");
|
|
43
|
+
export class $ZodAsyncError extends Error {
|
|
44
|
+
constructor() {
|
|
45
|
+
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export const globalConfig = {};
|
|
49
|
+
export function config(newConfig) {
|
|
50
|
+
if (newConfig)
|
|
51
|
+
Object.assign(globalConfig, newConfig);
|
|
52
|
+
return globalConfig;
|
|
53
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
type ModeWriter = (doc: Doc, modes: {
|
|
2
|
+
execution: "sync" | "async";
|
|
3
|
+
}) => void;
|
|
4
|
+
export declare class Doc {
|
|
5
|
+
args: string[];
|
|
6
|
+
content: string[];
|
|
7
|
+
indent: number;
|
|
8
|
+
constructor(args?: string[]);
|
|
9
|
+
indented(fn: (doc: Doc) => void): void;
|
|
10
|
+
write(fn: ModeWriter): void;
|
|
11
|
+
write(line: string): void;
|
|
12
|
+
compile(): Function;
|
|
13
|
+
}
|
|
14
|
+
export {};
|