@es-joy/jsoe 0.28.0 → 0.28.1
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/CHANGES.md +4 -0
- package/dist/formats/schema.d.ts.map +1 -1
- package/dist/fundamentalTypes/arrayType.d.ts.map +1 -1
- package/dist/fundamentalTypes/stringType.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/typeChoices.d.ts.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +22 -9
- package/pnpm-workspace.yaml +31 -30
- package/src/formats/schema.js +7 -14
- package/src/fundamentalTypes/arrayType.js +14 -22
- package/src/fundamentalTypes/blobType.js +16 -16
- package/src/fundamentalTypes/fileType.js +13 -13
- package/src/fundamentalTypes/regexpType.js +1 -1
- package/src/fundamentalTypes/stringType.js +5 -0
- package/src/subTypes/blobHTMLType.js +1 -1
- package/src/superTypes/dommatrixType.js +1 -1
- package/src/superTypes/errorsSpecialType.js +1 -1
- package/src/typeChoices.js +1 -3
- package/src/types.js +0 -6
- package/src/utils/media.js +3 -3
- package/vendor/jamilih/dist/jml.mjs +898 -25
- package/vendor/zod/classic/checks.d.ts +1 -1
- package/vendor/zod/classic/checks.js +1 -1
- package/vendor/zod/classic/schemas.d.ts +2 -6
- package/vendor/zod/classic/schemas.js +9 -13
- package/vendor/zod/core/api.d.ts +8 -4
- package/vendor/zod/core/api.js +11 -23
- package/vendor/zod/core/checks.d.ts +16 -0
- package/vendor/zod/core/checks.js +31 -0
- package/vendor/zod/core/compile.js +20 -24
- package/vendor/zod/core/core.js +1 -1
- package/vendor/zod/core/json-schema-processors.d.ts +0 -1
- package/vendor/zod/core/json-schema-processors.js +8 -43
- package/vendor/zod/core/memoizer.js +2 -5
- package/vendor/zod/core/regexes.d.ts +1 -0
- package/vendor/zod/core/regexes.js +2 -0
- package/vendor/zod/core/schemas.d.ts +8 -23
- package/vendor/zod/core/schemas.js +39 -80
- package/vendor/zod/core/to-json-schema.d.ts +0 -3
- package/vendor/zod/core/to-json-schema.js +1 -1
- package/vendor/zod/core/util.js +0 -4
- package/vendor/zod/core/versions.js +1 -1
- package/vendor/zod/core/visit.js +0 -12
- package/vendor/zod/locales/ar.js +1 -0
- package/vendor/zod/locales/az.js +1 -0
- package/vendor/zod/locales/be.js +1 -0
- package/vendor/zod/locales/bg.js +1 -0
- package/vendor/zod/locales/bn.js +1 -0
- package/vendor/zod/locales/ca.js +1 -0
- package/vendor/zod/locales/ckb.js +1 -0
- package/vendor/zod/locales/cs.js +1 -0
- package/vendor/zod/locales/da.js +1 -0
- package/vendor/zod/locales/de.js +1 -0
- package/vendor/zod/locales/el.js +1 -0
- package/vendor/zod/locales/en.js +1 -0
- package/vendor/zod/locales/eo.js +1 -0
- package/vendor/zod/locales/es.js +1 -0
- package/vendor/zod/locales/fa.js +1 -0
- package/vendor/zod/locales/fi.js +1 -0
- package/vendor/zod/locales/fr-CA.js +1 -0
- package/vendor/zod/locales/fr.js +1 -0
- package/vendor/zod/locales/gu.js +1 -0
- package/vendor/zod/locales/he.js +1 -0
- package/vendor/zod/locales/hi.js +1 -0
- package/vendor/zod/locales/hr.js +1 -0
- package/vendor/zod/locales/hu.js +1 -0
- package/vendor/zod/locales/hy.js +1 -0
- package/vendor/zod/locales/id.js +1 -0
- package/vendor/zod/locales/is.js +1 -0
- package/vendor/zod/locales/it.js +1 -0
- package/vendor/zod/locales/ja.js +1 -0
- package/vendor/zod/locales/ka.js +1 -0
- package/vendor/zod/locales/km.js +1 -0
- package/vendor/zod/locales/kn.js +1 -0
- package/vendor/zod/locales/ko.js +1 -0
- package/vendor/zod/locales/lt.js +1 -0
- package/vendor/zod/locales/mk.js +1 -0
- package/vendor/zod/locales/ms.js +1 -0
- package/vendor/zod/locales/ne.js +1 -0
- package/vendor/zod/locales/nl.js +1 -0
- package/vendor/zod/locales/nn.js +1 -0
- package/vendor/zod/locales/no.js +1 -0
- package/vendor/zod/locales/ota.js +1 -0
- package/vendor/zod/locales/pl.js +1 -0
- package/vendor/zod/locales/ps.js +1 -0
- package/vendor/zod/locales/pt-BR.js +1 -0
- package/vendor/zod/locales/pt.js +1 -0
- package/vendor/zod/locales/ro.js +1 -0
- package/vendor/zod/locales/ru.js +1 -0
- package/vendor/zod/locales/sk.js +1 -0
- package/vendor/zod/locales/sl.js +1 -0
- package/vendor/zod/locales/sv.js +1 -0
- package/vendor/zod/locales/ta.js +1 -0
- package/vendor/zod/locales/tg.js +1 -0
- package/vendor/zod/locales/th.js +1 -0
- package/vendor/zod/locales/tk.js +1 -0
- package/vendor/zod/locales/tr.js +1 -0
- package/vendor/zod/locales/uk.js +1 -0
- package/vendor/zod/locales/ur.js +1 -0
- package/vendor/zod/locales/uz.js +1 -0
- package/vendor/zod/locales/vi.js +1 -0
- package/vendor/zod/locales/yo.js +1 -0
- package/vendor/zod/locales/zh-CN.js +1 -0
- package/vendor/zod/locales/zh-TW.js +1 -0
- package/vendor/zod/mini/checks.d.ts +1 -1
- package/vendor/zod/mini/checks.js +1 -1
- package/vendor/zod/mini/schemas.d.ts +2 -5
- package/vendor/zod/mini/schemas.js +9 -11
- package/vendor/zodexy/dist/esm/index.js +4 -33
- package/vendor/zodexy/dist/schema.zodexy.json +1 -17
|
@@ -1 +1 @@
|
|
|
1
|
-
export { _lt as lt, _lte as lte, _gt as gt, _gte as gte, _positive as positive, _negative as negative, _nonpositive as nonpositive, _nonnegative as nonnegative, _multipleOf as multipleOf, _maxSize as maxSize, _minSize as minSize, _size as size, _maxLength as maxLength, _minLength as minLength, _length as length, _regex as regex, _lowercase as lowercase, _uppercase as uppercase, _includes as includes, _startsWith as startsWith, _endsWith as endsWith, _property as property, _mime as mime, _overwrite as overwrite, _normalize as normalize, _trim as trim, _toLowerCase as toLowerCase, _toUpperCase as toUpperCase, _slugify as slugify, type $RefinementCtx as RefinementCtx, } from "../core/index.js";
|
|
1
|
+
export { _lt as lt, _lte as lte, _gt as gt, _gte as gte, _positive as positive, _negative as negative, _nonpositive as nonpositive, _nonnegative as nonnegative, _multipleOf as multipleOf, _maxSize as maxSize, _minSize as minSize, _size as size, _maxLength as maxLength, _minLength as minLength, _length as length, _regex as regex, _lowercase as lowercase, _uppercase as uppercase, _includes as includes, _startsWith as startsWith, _endsWith as endsWith, _property as property, _properties as properties, _mime as mime, _overwrite as overwrite, _normalize as normalize, _trim as trim, _toLowerCase as toLowerCase, _toUpperCase as toUpperCase, _slugify as slugify, type $RefinementCtx as RefinementCtx, } from "../core/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { _lt as lt, _lte as lte, _gt as gt, _gte as gte, _positive as positive, _negative as negative, _nonpositive as nonpositive, _nonnegative as nonnegative, _multipleOf as multipleOf, _maxSize as maxSize, _minSize as minSize, _size as size, _maxLength as maxLength, _minLength as minLength, _length as length, _regex as regex, _lowercase as lowercase, _uppercase as uppercase, _includes as includes, _startsWith as startsWith, _endsWith as endsWith, _property as property, _mime as mime, _overwrite as overwrite, _normalize as normalize, _trim as trim, _toLowerCase as toLowerCase, _toUpperCase as toUpperCase, _slugify as slugify, } from "../core/index.js";
|
|
1
|
+
export { _lt as lt, _lte as lte, _gt as gt, _gte as gte, _positive as positive, _negative as negative, _nonpositive as nonpositive, _nonnegative as nonnegative, _multipleOf as multipleOf, _maxSize as maxSize, _minSize as minSize, _size as size, _maxLength as maxLength, _minLength as minLength, _length as length, _regex as regex, _lowercase as lowercase, _uppercase as uppercase, _includes as includes, _startsWith as startsWith, _endsWith as endsWith, _property as property, _properties as properties, _mime as mime, _overwrite as overwrite, _normalize as normalize, _trim as trim, _toLowerCase as toLowerCase, _toUpperCase as toUpperCase, _slugify as slugify, } from "../core/index.js";
|
|
@@ -330,6 +330,7 @@ export declare const ZodCustomStringFormat: core.$constructor<ZodCustomStringFor
|
|
|
330
330
|
export declare function stringFormat<Format extends string>(format: Format, fnOrRegex: ((arg: string) => util.MaybeAsync<unknown>) | RegExp, _params?: string | core.$ZodStringFormatParams): ZodCustomStringFormat<Format>;
|
|
331
331
|
export declare function hostname(_params?: string | core.$ZodStringFormatParams): ZodCustomStringFormat<"hostname">;
|
|
332
332
|
export declare function hex(_params?: string | core.$ZodStringFormatParams): ZodCustomStringFormat<"hex">;
|
|
333
|
+
export declare function currencyCode(_params?: string | core.$ZodStringFormatParams): ZodCustomStringFormat<"currency_code">;
|
|
333
334
|
export declare function hash<Alg extends util.HashAlgorithm, Enc extends util.HashEncoding = "hex">(alg: Alg, params?: {
|
|
334
335
|
enc?: Enc;
|
|
335
336
|
} & core.$ZodStringFormatParams): ZodCustomStringFormat<`${Alg}_${Enc}`>;
|
|
@@ -779,11 +780,6 @@ export interface ZodCustom<O = unknown, I = unknown> extends _ZodType<core.$ZodC
|
|
|
779
780
|
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
780
781
|
}
|
|
781
782
|
export declare const ZodCustom: core.$constructor<ZodCustom>;
|
|
782
|
-
export interface ZodProperties<Shape extends core.$ZodShape = core.$ZodShape> extends _ZodType<core.$ZodPropertiesInternals<Shape>>, core.$ZodProperties<Shape> {
|
|
783
|
-
"~standard": ZodStandardSchemaWithJSON<this>;
|
|
784
|
-
}
|
|
785
|
-
export declare const ZodProperties: core.$constructor<ZodProperties>;
|
|
786
|
-
export declare function properties<Shape extends core.$ZodShape>(shape: Shape, params?: string | core.$ZodPropertiesParams): ZodProperties<Shape>;
|
|
787
783
|
export declare function check<O = unknown>(fn: core.CheckFn<O>): core.$ZodCheck<O>;
|
|
788
784
|
export declare function custom<O>(fn?: (data: unknown) => unknown, _params?: string | core.$ZodCustomParams | undefined): ZodCustom<O, O>;
|
|
789
785
|
export declare function refine<T>(fn: (arg: NoInfer<T>) => util.MaybeAsync<unknown>, _params?: string | core.$ZodCustomParams): core.$ZodCheck<T>;
|
|
@@ -792,7 +788,7 @@ export declare const describe: typeof core.describe;
|
|
|
792
788
|
export declare const meta: typeof core.meta;
|
|
793
789
|
type ZodInstanceOfParams = core.Params<ZodCustom, core.$ZodIssueCustom, "type" | "check" | "checks" | "fn" | "abort" | "error" | "params" | "path">;
|
|
794
790
|
export interface ZodInstanceOf<T = unknown> extends ZodCustom<T, T> {
|
|
795
|
-
properties<Shape extends core.$ZodShape>(shape: Shape, params?: string | core.$
|
|
791
|
+
properties<Shape extends core.$ZodShape>(shape: Shape, params?: string | core.$ZodCheckPropertiesParams): ZodInstanceOf<T & core.$InferObjectInput<Shape, {}>>;
|
|
796
792
|
}
|
|
797
793
|
export declare const ZodInstanceOf: core.$constructor<ZodInstanceOf>;
|
|
798
794
|
declare function _instanceof<T extends typeof util.Class>(cls: T, params?: ZodInstanceOfParams): ZodInstanceOf<InstanceType<T>>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as core from "../core/index.js";
|
|
2
2
|
import { util } from "../core/index.js";
|
|
3
3
|
import * as processors from "../core/json-schema-processors.js";
|
|
4
|
+
import * as regexes from "../core/regexes.js";
|
|
4
5
|
import { createStandardJSONSchemaMethod, createToJSONSchemaMethod } from "../core/to-json-schema.js";
|
|
5
6
|
import en from "../locales/en.js";
|
|
6
7
|
import * as checks from "./checks.js";
|
|
@@ -399,8 +400,8 @@ export function url(params) {
|
|
|
399
400
|
}
|
|
400
401
|
export function httpUrl(params) {
|
|
401
402
|
return core._url(ZodURL, {
|
|
402
|
-
protocol:
|
|
403
|
-
hostname:
|
|
403
|
+
protocol: regexes.httpProtocol,
|
|
404
|
+
hostname: regexes.domain,
|
|
404
405
|
...util.normalizeParams(params),
|
|
405
406
|
});
|
|
406
407
|
}
|
|
@@ -565,10 +566,13 @@ export function stringFormat(format, fnOrRegex, _params = {}) {
|
|
|
565
566
|
return core._stringFormat(ZodCustomStringFormat, format, fnOrRegex, _params);
|
|
566
567
|
}
|
|
567
568
|
export function hostname(_params) {
|
|
568
|
-
return core._stringFormat(ZodCustomStringFormat, "hostname",
|
|
569
|
+
return core._stringFormat(ZodCustomStringFormat, "hostname", regexes.hostname, _params);
|
|
569
570
|
}
|
|
570
571
|
export function hex(_params) {
|
|
571
|
-
return core._stringFormat(ZodCustomStringFormat, "hex",
|
|
572
|
+
return core._stringFormat(ZodCustomStringFormat, "hex", regexes.hex, _params);
|
|
573
|
+
}
|
|
574
|
+
export function currencyCode(_params) {
|
|
575
|
+
return core._stringFormat(ZodCustomStringFormat, "currency_code", regexes.currencyCode, _params);
|
|
572
576
|
}
|
|
573
577
|
export function hash(alg, params) {
|
|
574
578
|
const enc = params?.enc ?? "hex";
|
|
@@ -1455,14 +1459,6 @@ export const ZodCustom = /*@__PURE__*/ core.$constructor("ZodCustom", (inst, def
|
|
|
1455
1459
|
ZodType.init(inst, def);
|
|
1456
1460
|
inst._zod.processJSONSchema = (ctx, json, params) => processors.customProcessor(inst, ctx, json, params);
|
|
1457
1461
|
});
|
|
1458
|
-
export const ZodProperties = /*@__PURE__*/ core.$constructor("ZodProperties", (inst, def) => {
|
|
1459
|
-
_ensureDefaultMemoizer();
|
|
1460
|
-
core.$ZodProperties.init(inst, def);
|
|
1461
|
-
ZodType.init(inst, def);
|
|
1462
|
-
});
|
|
1463
|
-
export function properties(shape, params) {
|
|
1464
|
-
return core._properties(ZodProperties, shape, params);
|
|
1465
|
-
}
|
|
1466
1462
|
// custom checks
|
|
1467
1463
|
export function check(fn) {
|
|
1468
1464
|
const ch = new core.$ZodCheck({
|
|
@@ -1490,7 +1486,7 @@ export const ZodInstanceOf = /*@__PURE__*/ core.$constructor("ZodInstanceOf", (i
|
|
|
1490
1486
|
}, {
|
|
1491
1487
|
properties(shape, params) {
|
|
1492
1488
|
// asserts in place, so the narrowed output type is truthful without a wrapper
|
|
1493
|
-
return this.check(
|
|
1489
|
+
return this.check(core._properties(shape, params));
|
|
1494
1490
|
},
|
|
1495
1491
|
});
|
|
1496
1492
|
function _instanceof(cls, params = {}) {
|
package/vendor/zod/core/api.d.ts
CHANGED
|
@@ -17,7 +17,9 @@ AlsoOmit extends Exclude<keyof T["_zod"]["def"], "check" | "error"> = never> = P
|
|
|
17
17
|
export type StringFormatParams<T extends schemas.$ZodStringFormat = schemas.$ZodStringFormat, AlsoOmit extends Exclude<keyof T["_zod"]["def"], "type" | "coerce" | "checks" | "error" | "check" | "format"> = never> = Params<T, NonNullable<T["_zod"]["isst"] | T["_zod"]["issc"]>, "type" | "coerce" | "checks" | "error" | "check" | "format" | AlsoOmit>;
|
|
18
18
|
export type CheckStringFormatParams<T extends schemas.$ZodStringFormat = schemas.$ZodStringFormat, AlsoOmit extends Exclude<keyof T["_zod"]["def"], "type" | "coerce" | "checks" | "error" | "check" | "format"> = never> = Params<T, NonNullable<T["_zod"]["issc"]>, "type" | "coerce" | "checks" | "error" | "check" | "format" | AlsoOmit>;
|
|
19
19
|
export type CheckTypeParams<T extends schemas.$ZodType & checks.$ZodCheck = schemas.$ZodType & checks.$ZodCheck, AlsoOmit extends Exclude<keyof T["_zod"]["def"], "type" | "checks" | "error" | "check"> = never> = Params<T, NonNullable<T["_zod"]["isst"] | T["_zod"]["issc"]>, "type" | "checks" | "error" | "check" | AlsoOmit>;
|
|
20
|
-
export type $ZodStringParams = TypeParams<schemas.$ZodString<string>, "coerce"
|
|
20
|
+
export type $ZodStringParams = TypeParams<schemas.$ZodString<string>, "coerce"> & {
|
|
21
|
+
checks?: readonly checks.$ZodCheck<string>[];
|
|
22
|
+
};
|
|
21
23
|
export declare function _string<T extends schemas.$ZodString>(Class: util.SchemaClass<T>, params?: string | $ZodStringParams): T;
|
|
22
24
|
export declare function _coercedString<T extends schemas.$ZodString>(Class: util.SchemaClass<T>, params?: string | $ZodStringParams): T;
|
|
23
25
|
export type $ZodStringFormatParams = CheckTypeParams<schemas.$ZodStringFormat, "format" | "coerce" | "when" | "pattern">;
|
|
@@ -131,7 +133,9 @@ export declare function _isoTime<T extends schemas.$ZodISOTime>(Class: util.Sche
|
|
|
131
133
|
export type $ZodISODurationParams = StringFormatParams<schemas.$ZodISODuration, "when">;
|
|
132
134
|
export type $ZodCheckISODurationParams = CheckStringFormatParams<schemas.$ZodISODuration, "when">;
|
|
133
135
|
export declare function _isoDuration<T extends schemas.$ZodISODuration>(Class: util.SchemaClass<T>, params?: string | $ZodISODurationParams | $ZodCheckISODurationParams): T;
|
|
134
|
-
export type $ZodNumberParams = TypeParams<schemas.$ZodNumber<number>, "coerce"
|
|
136
|
+
export type $ZodNumberParams = TypeParams<schemas.$ZodNumber<number>, "coerce"> & {
|
|
137
|
+
checks?: readonly checks.$ZodCheck<number>[];
|
|
138
|
+
};
|
|
135
139
|
export type $ZodNumberFormatParams = CheckTypeParams<schemas.$ZodNumberFormat, "format" | "coerce">;
|
|
136
140
|
export type $ZodCheckNumberFormatParams = CheckParams<checks.$ZodCheckNumberFormat, "format" | "when">;
|
|
137
141
|
export declare function _number<T extends schemas.$ZodNumber>(Class: util.SchemaClass<T>, params?: string | $ZodNumberParams): T;
|
|
@@ -216,8 +220,8 @@ export type $ZodCheckPropertyParams = CheckParams<checks.$ZodCheckProperty, "pro
|
|
|
216
220
|
export declare function _property<K extends string, T extends schemas.$ZodType>(property: K, schema: T, params?: string | $ZodCheckPropertyParams): checks.$ZodCheckProperty<{
|
|
217
221
|
[k in K]: util.Widen<core.input<T>>;
|
|
218
222
|
}>;
|
|
219
|
-
export type $
|
|
220
|
-
export declare function _properties<Shape extends schemas.$ZodShape>(
|
|
223
|
+
export type $ZodCheckPropertiesParams = CheckParams<checks.$ZodCheckProperties, "shape" | "when">;
|
|
224
|
+
export declare function _properties<Shape extends schemas.$ZodShape>(shape: Shape, params?: string | $ZodCheckPropertiesParams): checks.$ZodCheckProperties<Shape>;
|
|
221
225
|
export type $ZodCheckMimeTypeParams = CheckParams<checks.$ZodCheckMimeType, "mime" | "when">;
|
|
222
226
|
export declare function _mime(types: util.MimeTypes[], params?: string | $ZodCheckMimeTypeParams): checks.$ZodCheckMimeType;
|
|
223
227
|
export declare function _overwrite<T>(tx: (input: T) => T): checks.$ZodCheckOverwrite<T>;
|
package/vendor/zod/core/api.js
CHANGED
|
@@ -2,20 +2,18 @@ import * as checks from "./checks.js";
|
|
|
2
2
|
import * as registries from "./registries.js";
|
|
3
3
|
import * as schemas from "./schemas.js";
|
|
4
4
|
import * as util from "./util.js";
|
|
5
|
+
function snapshotChecks(def) {
|
|
6
|
+
if (def.checks)
|
|
7
|
+
def.checks = [...def.checks];
|
|
8
|
+
return def;
|
|
9
|
+
}
|
|
5
10
|
// @__NO_SIDE_EFFECTS__
|
|
6
11
|
export function _string(Class, params) {
|
|
7
|
-
return new Class({
|
|
8
|
-
type: "string",
|
|
9
|
-
...util.normalizeParams(params),
|
|
10
|
-
});
|
|
12
|
+
return new Class(snapshotChecks({ type: "string", ...util.normalizeParams(params) }));
|
|
11
13
|
}
|
|
12
14
|
// @__NO_SIDE_EFFECTS__
|
|
13
15
|
export function _coercedString(Class, params) {
|
|
14
|
-
return new Class({
|
|
15
|
-
type: "string",
|
|
16
|
-
coerce: true,
|
|
17
|
-
...util.normalizeParams(params),
|
|
18
|
-
});
|
|
16
|
+
return new Class(snapshotChecks({ type: "string", coerce: true, ...util.normalizeParams(params) }));
|
|
19
17
|
}
|
|
20
18
|
// @__NO_SIDE_EFFECTS__
|
|
21
19
|
export function _email(Class, params) {
|
|
@@ -324,20 +322,11 @@ export function _isoDuration(Class, params) {
|
|
|
324
322
|
}
|
|
325
323
|
// @__NO_SIDE_EFFECTS__
|
|
326
324
|
export function _number(Class, params) {
|
|
327
|
-
return new Class({
|
|
328
|
-
type: "number",
|
|
329
|
-
checks: [],
|
|
330
|
-
...util.normalizeParams(params),
|
|
331
|
-
});
|
|
325
|
+
return new Class(snapshotChecks({ type: "number", checks: [], ...util.normalizeParams(params) }));
|
|
332
326
|
}
|
|
333
327
|
// @__NO_SIDE_EFFECTS__
|
|
334
328
|
export function _coercedNumber(Class, params) {
|
|
335
|
-
return new Class({
|
|
336
|
-
type: "number",
|
|
337
|
-
coerce: true,
|
|
338
|
-
checks: [],
|
|
339
|
-
...util.normalizeParams(params),
|
|
340
|
-
});
|
|
329
|
+
return new Class(snapshotChecks({ type: "number", coerce: true, checks: [], ...util.normalizeParams(params) }));
|
|
341
330
|
}
|
|
342
331
|
// @__NO_SIDE_EFFECTS__
|
|
343
332
|
export function _int(Class, params) {
|
|
@@ -688,9 +677,8 @@ export function _property(property, schema, params) {
|
|
|
688
677
|
});
|
|
689
678
|
}
|
|
690
679
|
// @__NO_SIDE_EFFECTS__
|
|
691
|
-
export function _properties(
|
|
692
|
-
return new
|
|
693
|
-
type: "properties",
|
|
680
|
+
export function _properties(shape, params) {
|
|
681
|
+
return new checks.$ZodCheckProperties({
|
|
694
682
|
check: "properties",
|
|
695
683
|
shape,
|
|
696
684
|
...util.normalizeParams(params),
|
|
@@ -250,6 +250,22 @@ export interface $ZodCheckProperty<T extends object = object> extends $ZodCheck<
|
|
|
250
250
|
_zod: $ZodCheckPropertyInternals<T>;
|
|
251
251
|
}
|
|
252
252
|
export declare const $ZodCheckProperty: core.$constructor<$ZodCheckProperty>;
|
|
253
|
+
export interface $ZodCheckPropertiesDef<Shape extends schemas.$ZodShape = schemas.$ZodShape> extends $ZodCheckDef {
|
|
254
|
+
check: "properties";
|
|
255
|
+
shape: Shape;
|
|
256
|
+
}
|
|
257
|
+
export type $ZodCheckPropertiesInput<Shape extends schemas.$ZodShape = schemas.$ZodShape> = {
|
|
258
|
+
-readonly [k in keyof Shape]: util.Widen<core.input<Shape[k]>>;
|
|
259
|
+
};
|
|
260
|
+
export interface $ZodCheckPropertiesInternals<Shape extends schemas.$ZodShape = schemas.$ZodShape> extends $ZodCheckInternals<$ZodCheckPropertiesInput<Shape>> {
|
|
261
|
+
def: $ZodCheckPropertiesDef<Shape>;
|
|
262
|
+
issc: errors.$ZodIssue;
|
|
263
|
+
}
|
|
264
|
+
export interface $ZodCheckProperties<Shape extends schemas.$ZodShape = schemas.$ZodShape> extends $ZodCheck<$ZodCheckPropertiesInput<Shape>> {
|
|
265
|
+
_zod: $ZodCheckPropertiesInternals<Shape>;
|
|
266
|
+
[Symbol.iterator](): Iterator<this>;
|
|
267
|
+
}
|
|
268
|
+
export declare const $ZodCheckProperties: core.$constructor<$ZodCheckProperties>;
|
|
253
269
|
export interface $ZodCheckMimeTypeDef extends $ZodCheckDef {
|
|
254
270
|
check: "mime_type";
|
|
255
271
|
mime: util.MimeTypes[];
|
|
@@ -462,6 +462,37 @@ export const $ZodCheckProperty = /*@__PURE__*/ core.$constructor("$ZodCheckPrope
|
|
|
462
462
|
return;
|
|
463
463
|
};
|
|
464
464
|
});
|
|
465
|
+
export const $ZodCheckProperties = /*@__PURE__*/ core.$constructor("$ZodCheckProperties", (inst, def) => {
|
|
466
|
+
$ZodCheck.init(inst, def);
|
|
467
|
+
util.hide(inst, Symbol.iterator, function* () {
|
|
468
|
+
yield inst;
|
|
469
|
+
});
|
|
470
|
+
// key and schema snapshotted together: reading one live and the other cached lets a later mutation of the caller's shape object pair a stale key with a missing schema
|
|
471
|
+
let entries;
|
|
472
|
+
inst._zod.check = (payload) => {
|
|
473
|
+
// the base schema already typed the value, so only a nullish one is rejected here: the properties read on a primitive too, matching z.property() on a string's length
|
|
474
|
+
if (payload.value == null) {
|
|
475
|
+
payload.issues.push({ expected: "object", code: "invalid_type", input: payload.value, inst });
|
|
476
|
+
return undefined;
|
|
477
|
+
}
|
|
478
|
+
entries ?? (entries = Reflect.ownKeys(def.shape).map((key) => [key, def.shape[key]]));
|
|
479
|
+
const input = payload.value;
|
|
480
|
+
let proms;
|
|
481
|
+
for (const [key, schema] of entries) {
|
|
482
|
+
const result = schema._zod.run({ value: input[key], issues: [] }, {});
|
|
483
|
+
if (result instanceof Promise) {
|
|
484
|
+
proms ?? (proms = []);
|
|
485
|
+
proms.push(result.then((result) => handleCheckPropertyResult(result, payload, key)));
|
|
486
|
+
}
|
|
487
|
+
else {
|
|
488
|
+
handleCheckPropertyResult(result, payload, key);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
if (proms)
|
|
492
|
+
return Promise.all(proms).then(() => undefined);
|
|
493
|
+
return undefined;
|
|
494
|
+
};
|
|
495
|
+
});
|
|
465
496
|
export const $ZodCheckMimeType = /*@__PURE__*/ core.$constructor("$ZodCheckMimeType", (inst, def) => {
|
|
466
497
|
$ZodCheck.init(inst, def);
|
|
467
498
|
const mimeSet = new Set(def.mime);
|
|
@@ -2,7 +2,7 @@ import { $ZodAsyncError } from "./core.js";
|
|
|
2
2
|
import { Doc } from "./doc.js";
|
|
3
3
|
import { isBackEdge, isRecursiveSchema } from "./memoizer.js";
|
|
4
4
|
import * as regexes from "./regexes.js";
|
|
5
|
-
import { isValidBase64, isValidBase64URL, isValidCIDRv6, isValidCreditCard, isValidIBAN, isValidIPv6, isValidJWT, mergeValues,
|
|
5
|
+
import { isValidBase64, isValidBase64URL, isValidCIDRv6, isValidCreditCard, isValidIBAN, isValidIPv6, isValidJWT, mergeValues, stripTabAndNewline, urlHostnameOk, urlProtocolOk, validateURL, } from "./schemas.js";
|
|
6
6
|
import * as util from "./util.js";
|
|
7
7
|
/** @internal Sentinel the compiled fast path returns when validation fails. */
|
|
8
8
|
export const INVALID = Symbol.for("zod.compile.invalid");
|
|
@@ -330,7 +330,7 @@ function generateChecks(doc, ctx, schema, accessor) {
|
|
|
330
330
|
generatePropertyCheck(doc, ctx, def, currentAccessor);
|
|
331
331
|
break;
|
|
332
332
|
case "properties":
|
|
333
|
-
generatePropertiesChecks(doc, ctx, def, currentAccessor
|
|
333
|
+
generatePropertiesChecks(doc, ctx, def, currentAccessor);
|
|
334
334
|
break;
|
|
335
335
|
case "overwrite": {
|
|
336
336
|
// Overwrite transforms the value - create new variable for transformed result
|
|
@@ -458,15 +458,13 @@ function generateMimeTypeCheck(doc, ctx, def, accessor) {
|
|
|
458
458
|
}
|
|
459
459
|
}
|
|
460
460
|
// asserts each named property in place; children compile assert-only because z.properties never rebuilds its input
|
|
461
|
-
function generatePropertiesChecks(doc, ctx, def, accessor
|
|
462
|
-
// a custom `when` gates the assertion at runtime; inside a union a wrongly-run branch is absorbed as a branch failure rather than falling back, so refuse at codegen
|
|
461
|
+
function generatePropertiesChecks(doc, ctx, def, accessor) {
|
|
462
|
+
// a custom `when` gates the assertion at runtime; inside a union a wrongly-run branch is absorbed as a branch failure rather than falling back, so refuse at codegen
|
|
463
463
|
if (def.when) {
|
|
464
464
|
throw new ZodCompileUnsupportedError(`check with a custom "when" condition`);
|
|
465
465
|
}
|
|
466
|
-
// matches the runtime gate
|
|
467
|
-
doc.write(
|
|
468
|
-
? `if (${accessor} === null || (typeof ${accessor} !== "object" && typeof ${accessor} !== "function")) return INVALID;`
|
|
469
|
-
: `if (${accessor} == null) return INVALID;`);
|
|
466
|
+
// matches the runtime gate: the base schema already typed the value, so only a nullish one is rejected
|
|
467
|
+
doc.write(`if (${accessor} == null) return INVALID;`);
|
|
470
468
|
const shape = def.shape;
|
|
471
469
|
for (const key of Reflect.ownKeys(shape)) {
|
|
472
470
|
// a symbol has no source literal, so it is hoisted as a constant
|
|
@@ -579,8 +577,7 @@ const PATTERN_IS_COMPLETE = new Set([
|
|
|
579
577
|
"uuid",
|
|
580
578
|
"xid",
|
|
581
579
|
]);
|
|
582
|
-
|
|
583
|
-
function generateStringFormatCheck(doc, ctx, def, accessor) {
|
|
580
|
+
function generateStringFormatCheck(doc, ctx, def, accessor, needsValue = true) {
|
|
584
581
|
// Some string formats do runtime validation beyond their advertised pattern. For cheap pure utility checks, hoist the runtime function and call it so the fast path stays correct without cloning the utility logic into codegen.
|
|
585
582
|
const fmt = def.format;
|
|
586
583
|
if (fmt === "base64") {
|
|
@@ -626,7 +623,7 @@ function generateStringFormatCheck(doc, ctx, def, accessor) {
|
|
|
626
623
|
formatDef.hostname !== undefined ||
|
|
627
624
|
formatDef.protocol !== undefined) {
|
|
628
625
|
// Same three predicates the runtime calls, in the same order, so there is no second URL implementation to drift. Which options exist is known now, so the calls the runtime makes conditionally are emitted conditionally instead.
|
|
629
|
-
const parseConst = addConstant(ctx,
|
|
626
|
+
const parseConst = addConstant(ctx, validateURL);
|
|
630
627
|
const defConst = addConstant(ctx, def);
|
|
631
628
|
const trimVar = newVar(ctx);
|
|
632
629
|
const urlVar = newVar(ctx);
|
|
@@ -641,6 +638,8 @@ function generateStringFormatCheck(doc, ctx, def, accessor) {
|
|
|
641
638
|
const protocolConst = addConstant(ctx, urlProtocolOk);
|
|
642
639
|
doc.write(`if (!${protocolConst}(${urlVar}, ${defConst}.protocol)) return INVALID;`);
|
|
643
640
|
}
|
|
641
|
+
if (!needsValue)
|
|
642
|
+
return null;
|
|
644
643
|
const outputVar = newVar(ctx);
|
|
645
644
|
const outputExpr = formatDef.normalize ? `${urlVar}.href` : `${addConstant(ctx, stripTabAndNewline)}(${trimVar})`;
|
|
646
645
|
doc.write(`const ${outputVar} = ${outputExpr};`);
|
|
@@ -705,7 +704,7 @@ function generateCheck(doc, ctx, schema, accessor, needsValue = true) {
|
|
|
705
704
|
let typeAccessor;
|
|
706
705
|
switch (type) {
|
|
707
706
|
case "string":
|
|
708
|
-
typeAccessor = generateStringCheck(doc, ctx, schema, accessor);
|
|
707
|
+
typeAccessor = generateStringCheck(doc, ctx, schema, accessor, buildsValue);
|
|
709
708
|
break;
|
|
710
709
|
case "number":
|
|
711
710
|
typeAccessor = generateNumberCheck(doc, schema, accessor);
|
|
@@ -817,10 +816,6 @@ function generateCheck(doc, ctx, schema, accessor, needsValue = true) {
|
|
|
817
816
|
case "custom":
|
|
818
817
|
typeAccessor = generateCustomCheck(doc, ctx, schema, accessor);
|
|
819
818
|
break;
|
|
820
|
-
case "properties":
|
|
821
|
-
generatePropertiesChecks(doc, ctx, schema._zod.def, accessor, true);
|
|
822
|
-
typeAccessor = accessor;
|
|
823
|
-
break;
|
|
824
819
|
case "transform":
|
|
825
820
|
typeAccessor = generateTransformCheck(doc, ctx, schema, accessor);
|
|
826
821
|
break;
|
|
@@ -838,13 +833,13 @@ function generateCheck(doc, ctx, schema, accessor, needsValue = true) {
|
|
|
838
833
|
// Generate checks after the type-specific validation (may transform value)
|
|
839
834
|
return generateChecks(doc, ctx, schema, typeAccessor);
|
|
840
835
|
}
|
|
841
|
-
function generateStringCheck(doc, ctx, schema, accessor) {
|
|
836
|
+
function generateStringCheck(doc, ctx, schema, accessor, needsValue = true) {
|
|
842
837
|
doc.write(`if (typeof ${accessor} !== "string") return INVALID;`);
|
|
843
838
|
// z.email() carries its format on the def, z.string().email() in def.checks; both route here so the format table has no second copy to drift from.
|
|
844
839
|
const def = schema._zod.def;
|
|
845
840
|
if (def.format === undefined)
|
|
846
841
|
return accessor;
|
|
847
|
-
return generateStringFormatCheck(doc, ctx, def, accessor);
|
|
842
|
+
return generateStringFormatCheck(doc, ctx, def, accessor, needsValue);
|
|
848
843
|
}
|
|
849
844
|
function generateNumberCheck(doc, schema, accessor) {
|
|
850
845
|
// Runtime z.number() rejects NaN and ±Infinity. Number.isFinite covers both.
|
|
@@ -979,9 +974,9 @@ function generateObjectCheck(doc, ctx, schema, accessor, buildsValue = true) {
|
|
|
979
974
|
}
|
|
980
975
|
}
|
|
981
976
|
// else: strip mode (no catchall) - unknown keys ignored, only include known keys
|
|
982
|
-
//
|
|
977
|
+
// defaulted required outputs keep their keys even when undefined
|
|
983
978
|
const outputVar = newVar(ctx);
|
|
984
|
-
const hasConditionalKeys = allKeys.some((k) =>
|
|
979
|
+
const hasConditionalKeys = allKeys.some((k) => mayOmitUndefined(propShape[k]) || dropsWhenAbsent(propShape[k]));
|
|
985
980
|
// Assert mode: every declared key is validated above, so the output literal and the unknown-key copy are pure waste. A `never` catchall already emitted its rejection loop; a schema catchall still has to validate the values it would otherwise have stored.
|
|
986
981
|
if (!buildsValue) {
|
|
987
982
|
if (unknownKeysMode === "schema") {
|
|
@@ -1011,7 +1006,7 @@ function generateObjectCheck(doc, ctx, schema, accessor, buildsValue = true) {
|
|
|
1011
1006
|
if (dropsWhenAbsent(propShape[k])) {
|
|
1012
1007
|
doc.write(`if (${kx} in ${accessor}) ${outputVar}[${kx}] = ${out};`);
|
|
1013
1008
|
}
|
|
1014
|
-
else if (
|
|
1009
|
+
else if (mayOmitUndefined(propShape[k])) {
|
|
1015
1010
|
doc.write(`if (${out} !== undefined || ${kx} in ${accessor}) ${outputVar}[${kx}] = ${out};`);
|
|
1016
1011
|
}
|
|
1017
1012
|
else {
|
|
@@ -1154,9 +1149,10 @@ function fastPathAcceptsAbsence(schema) {
|
|
|
1154
1149
|
function dropsWhenAbsent(schema) {
|
|
1155
1150
|
return schema._zod.optin === "optional" && schema._zod.optout === "optional";
|
|
1156
1151
|
}
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1152
|
+
function mayOmitUndefined(schema) {
|
|
1153
|
+
return (schema._zod.optin !== "defaulted" || schema._zod.optout === "optional") && mayOutputUndefined(schema);
|
|
1154
|
+
}
|
|
1155
|
+
// whether a schema's success-path output can be undefined
|
|
1160
1156
|
function mayOutputUndefined(schema) {
|
|
1161
1157
|
const def = schema._zod.def;
|
|
1162
1158
|
switch (def.type) {
|
package/vendor/zod/core/core.js
CHANGED
|
@@ -41,7 +41,6 @@ export declare const mapProcessor: Processor<schemas.$ZodMap>;
|
|
|
41
41
|
export declare const setProcessor: Processor<schemas.$ZodSet>;
|
|
42
42
|
export declare const arrayProcessor: Processor<schemas.$ZodArray>;
|
|
43
43
|
export declare const objectProcessor: Processor<schemas.$ZodObject>;
|
|
44
|
-
export declare const propertiesProcessor: Processor<schemas.$ZodProperties>;
|
|
45
44
|
export declare const unionProcessor: Processor<schemas.$ZodUnion>;
|
|
46
45
|
export declare const intersectionProcessor: Processor<schemas.$ZodIntersection>;
|
|
47
46
|
export declare const tupleProcessor: Processor<schemas.$ZodTuple>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as regexes from "./regexes.js";
|
|
2
2
|
import { base64Charset, base64urlCharset } from "./schemas.js";
|
|
3
|
-
import { extractDefs, finalize, handleUnrepresentable, initializeContext,
|
|
3
|
+
import { extractDefs, finalize, handleUnrepresentable, initializeContext, processSchema, } from "./to-json-schema.js";
|
|
4
4
|
import { BIGINT_FORMAT_RANGES, NUMBER_FORMAT_RANGES, assignProp, getEnumValues } from "./util.js";
|
|
5
5
|
const narrowMin = (agg, key, value) => {
|
|
6
6
|
if (agg[key] === undefined || value > agg[key])
|
|
@@ -395,18 +395,15 @@ export const objectProcessor = (schema, ctx, _json, params) => {
|
|
|
395
395
|
}));
|
|
396
396
|
}
|
|
397
397
|
// required keys
|
|
398
|
-
const
|
|
399
|
-
const
|
|
398
|
+
const requiredKeys = [];
|
|
399
|
+
for (const key of Object.keys(shape)) {
|
|
400
400
|
const field = def.shape[key];
|
|
401
|
-
if (ctx.io === "input") {
|
|
402
|
-
|
|
401
|
+
if (ctx.io === "input" ? inputOptin(field) === undefined : field._zod.optout === undefined) {
|
|
402
|
+
requiredKeys.push(key);
|
|
403
403
|
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
}));
|
|
408
|
-
if (requiredKeys.size > 0) {
|
|
409
|
-
json.required = Array.from(requiredKeys);
|
|
404
|
+
}
|
|
405
|
+
if (requiredKeys.length > 0) {
|
|
406
|
+
json.required = requiredKeys;
|
|
410
407
|
}
|
|
411
408
|
// catchall
|
|
412
409
|
if (def.catchall?._zod.def.type === "never") {
|
|
@@ -425,37 +422,6 @@ export const objectProcessor = (schema, ctx, _json, params) => {
|
|
|
425
422
|
});
|
|
426
423
|
}
|
|
427
424
|
};
|
|
428
|
-
// asserts named properties in place and passes everything else through, so no additionalProperties constraint is emitted
|
|
429
|
-
export const propertiesProcessor = (schema, ctx, _json, params) => {
|
|
430
|
-
const json = _json;
|
|
431
|
-
const def = schema._zod.def;
|
|
432
|
-
// dropping a symbol key silently would emit a schema that asserts less than this one does
|
|
433
|
-
if (Object.getOwnPropertySymbols(def.shape).length &&
|
|
434
|
-
handleUnrepresentable(schema, ctx, json, params, "Symbol keys cannot be represented in JSON Schema")) {
|
|
435
|
-
return;
|
|
436
|
-
}
|
|
437
|
-
// the parsed value is the input, so an output-mode emission would describe a transformed value this schema never returns
|
|
438
|
-
if (ctx.io === "output") {
|
|
439
|
-
for (const key in def.shape) {
|
|
440
|
-
if (isTransforming(def.shape[key]) &&
|
|
441
|
-
handleUnrepresentable(schema, ctx, json, params, `z.properties() returns its input, so the output of a transforming schema at key "${key}" cannot be represented in JSON Schema`)) {
|
|
442
|
-
return;
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
json.type = "object";
|
|
447
|
-
json.properties = {};
|
|
448
|
-
for (const key in def.shape) {
|
|
449
|
-
assignProp(json.properties, key, processSchema(def.shape[key], ctx, {
|
|
450
|
-
...params,
|
|
451
|
-
path: [...params.path, "properties", key],
|
|
452
|
-
}));
|
|
453
|
-
}
|
|
454
|
-
// input-side optionality in both modes: the parsed value is the input, so a defaulted key that stays absent must not be required of the output either
|
|
455
|
-
const required = Object.keys(def.shape).filter((key) => inputOptin(def.shape[key]) === undefined);
|
|
456
|
-
if (required.length > 0)
|
|
457
|
-
json.required = required;
|
|
458
|
-
};
|
|
459
425
|
export const unionProcessor = (schema, ctx, json, params) => {
|
|
460
426
|
const def = schema._zod.def;
|
|
461
427
|
// Exclusive unions (inclusive === false) use oneOf (exactly one match) instead of anyOf (one or more matches). This includes both z.xor() and discriminated unions
|
|
@@ -815,7 +781,6 @@ export const allProcessors = {
|
|
|
815
781
|
file: fileProcessor,
|
|
816
782
|
success: successProcessor,
|
|
817
783
|
custom: customProcessor,
|
|
818
|
-
properties: propertiesProcessor,
|
|
819
784
|
function: functionProcessor,
|
|
820
785
|
transform: transformProcessor,
|
|
821
786
|
map: mapProcessor,
|
|
@@ -8,9 +8,9 @@ export class $ZodCyclicError extends Error {
|
|
|
8
8
|
/** Keyed off the context object every schema in one parse call already shares. */
|
|
9
9
|
const STATE = "~memo";
|
|
10
10
|
const NO_ISSUES = [];
|
|
11
|
-
// a value a cycle can close through
|
|
11
|
+
// a value a cycle can close through
|
|
12
12
|
function isRef(value) {
|
|
13
|
-
return value !== null &&
|
|
13
|
+
return value !== null && typeof value === "object";
|
|
14
14
|
}
|
|
15
15
|
// Receivers prefix paths in place, so the cache and every hand-out need their own copies.
|
|
16
16
|
function cloneIssues(issues) {
|
|
@@ -67,9 +67,6 @@ function isRecursive(inst, stack, resolve) {
|
|
|
67
67
|
check(def.catchall);
|
|
68
68
|
break;
|
|
69
69
|
}
|
|
70
|
-
case "properties":
|
|
71
|
-
merge(shape(def.shape, false));
|
|
72
|
-
break;
|
|
73
70
|
case "array":
|
|
74
71
|
check(def.element);
|
|
75
72
|
break;
|
|
@@ -46,6 +46,7 @@ export declare const domain: RegExp;
|
|
|
46
46
|
export declare const httpProtocol: RegExp;
|
|
47
47
|
export declare const e164: RegExp;
|
|
48
48
|
export declare const creditCard: RegExp;
|
|
49
|
+
export declare const currencyCode: RegExp;
|
|
49
50
|
export declare const iban: RegExp;
|
|
50
51
|
export declare const date: RegExp;
|
|
51
52
|
export declare function time(args: {
|
|
@@ -66,6 +66,8 @@ export const httpProtocol = /^https?$/;
|
|
|
66
66
|
export const e164 = /^\+[1-9]\d{6,14}$/;
|
|
67
67
|
// Credit card shape: 12–19 digits, optionally separated by single spaces or single hyphens. ISO/IEC 7812 caps the PAN at 19 digits; 12 is the shortest issued length (Maestro).
|
|
68
68
|
export const creditCard = /^\d(?:[ -]?\d){11,18}$/;
|
|
69
|
+
// ISO 4217 alpha codes from the SIX list, regenerated by scripts/update-iso-4217.ts
|
|
70
|
+
export const currencyCode = /^(?:AED|AFN|ALL|AMD|AOA|ARS|AUD|AWG|AZN|BAM|BBD|BDT|BHD|BIF|BMD|BND|BOB|BOV|BRL|BSD|BTN|BWP|BYN|BZD|CAD|CDF|CHE|CHF|CHW|CLF|CLP|CNY|COP|COU|CRC|CUP|CVE|CZK|DJF|DKK|DOP|DZD|EGP|ERN|ETB|EUR|FJD|FKP|GBP|GEL|GHS|GIP|GMD|GNF|GTQ|GYD|HKD|HNL|HTG|HUF|IDR|ILS|INR|IQD|IRR|ISK|JMD|JOD|JPY|KES|KGS|KHR|KMF|KPW|KRW|KWD|KYD|KZT|LAK|LBP|LKR|LRD|LSL|LYD|MAD|MDL|MGA|MKD|MMK|MNT|MOP|MRU|MUR|MVR|MWK|MXN|MXV|MYR|MZN|NAD|NGN|NIO|NOK|NPR|NZD|OMR|PAB|PEN|PGK|PHP|PKR|PLN|PYG|QAR|RON|RSD|RUB|RWF|SAR|SBD|SCR|SDG|SEK|SGD|SHP|SLE|SOS|SRD|SSP|STN|SVC|SYP|SZL|THB|TJS|TMT|TND|TOP|TRY|TTD|TWD|TZS|UAH|UGX|USD|USN|UYI|UYU|UYW|UZS|VED|VES|VND|VUV|WST|XAD|XAF|XAG|XAU|XBA|XBB|XBC|XBD|XCD|XCG|XDR|XOF|XPD|XPF|XPT|XSU|XTS|XUA|XXX|YER|ZAR|ZMW|ZWG)$/;
|
|
69
71
|
// iban electronic format: 2-letter country, check digits 02-98 (the only values `98 - remainder` can produce), 11-30 bban characters
|
|
70
72
|
export const iban = /^[A-Z]{2}(?!00|01|99)\d{2}[A-Z0-9]{11,30}$/;
|
|
71
73
|
const dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
|
|
@@ -41,7 +41,7 @@ export interface ParsePayload<T = unknown> {
|
|
|
41
41
|
}
|
|
42
42
|
export type CheckFn<T> = (input: ParsePayload<T>) => util.MaybeAsync<void>;
|
|
43
43
|
export interface $ZodTypeDef {
|
|
44
|
-
type: "string" | "number" | "int" | "boolean" | "bigint" | "symbol" | "null" | "undefined" | "void" | "never" | "any" | "unknown" | "date" | "object" | "record" | "file" | "array" | "tuple" | "union" | "intersection" | "map" | "set" | "enum" | "literal" | "nullable" | "optional" | "nonoptional" | "success" | "transform" | "default" | "prefault" | "catch" | "nan" | "pipe" | "readonly" | "template_literal" | "promise" | "lazy" | "function" | "custom"
|
|
44
|
+
type: "string" | "number" | "int" | "boolean" | "bigint" | "symbol" | "null" | "undefined" | "void" | "never" | "any" | "unknown" | "date" | "object" | "record" | "file" | "array" | "tuple" | "union" | "intersection" | "map" | "set" | "enum" | "literal" | "nullable" | "optional" | "nonoptional" | "success" | "transform" | "default" | "prefault" | "catch" | "nan" | "pipe" | "readonly" | "template_literal" | "promise" | "lazy" | "function" | "custom";
|
|
45
45
|
error?: errors.$ZodErrorMap<never> | undefined;
|
|
46
46
|
checks?: checks.$ZodCheck<never>[];
|
|
47
47
|
}
|
|
@@ -188,9 +188,11 @@ export interface $ZodURL extends $ZodType {
|
|
|
188
188
|
}
|
|
189
189
|
/** The `://` guard rejected the input before the URL constructor saw it. */
|
|
190
190
|
export declare const URL_BAD_FORMAT = 1;
|
|
191
|
-
/** The URL
|
|
191
|
+
/** The URL parser rejected the input. */
|
|
192
192
|
export declare const URL_UNPARSEABLE = 2;
|
|
193
|
-
|
|
193
|
+
export declare function canParseURL(input: string): boolean;
|
|
194
|
+
export declare function validateURL(trimmed: string, def: Pick<$ZodURLDef, "protocol" | "hostname" | "normalize">): URL | true | typeof URL_BAD_FORMAT | typeof URL_UNPARSEABLE;
|
|
195
|
+
/** Parses a URL while preserving the non-normalizing HTTP guard. */
|
|
194
196
|
export declare function parseURLObject(trimmed: string, def: Pick<$ZodURLDef, "protocol" | "normalize">): URL | typeof URL_BAD_FORMAT | typeof URL_UNPARSEABLE;
|
|
195
197
|
/** The URL parser deletes every ASCII tab, LF and CR from its input before it parses, so `new URL("https://exa\nmple.com")` reports on `example.com`. Applying the same deletion to the returned value closes the half of that divergence which can move the host; the parser's other rewrite, stripping C0 controls at the edges, cannot. */
|
|
196
198
|
export declare function stripTabAndNewline(value: string): string;
|
|
@@ -1010,7 +1012,7 @@ export interface $ZodPrefaultDef<T extends SomeType = $ZodType> extends $ZodType
|
|
|
1010
1012
|
/** The default value. May be a getter. */
|
|
1011
1013
|
defaultValue: core.input<T>;
|
|
1012
1014
|
}
|
|
1013
|
-
export interface $ZodPrefaultInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<
|
|
1015
|
+
export interface $ZodPrefaultInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<core.output<T>, core.input<T> | undefined> {
|
|
1014
1016
|
def: $ZodPrefaultDef<T>;
|
|
1015
1017
|
optin: "defaulted";
|
|
1016
1018
|
optout?: "optional" | undefined;
|
|
@@ -1267,22 +1269,5 @@ export interface $ZodCustom<O = unknown, I = unknown> extends $ZodType {
|
|
|
1267
1269
|
_zod: $ZodCustomInternals<O, I>;
|
|
1268
1270
|
}
|
|
1269
1271
|
export declare const $ZodCustom: core.$constructor<$ZodCustom>;
|
|
1270
|
-
export
|
|
1271
|
-
|
|
1272
|
-
check: "properties";
|
|
1273
|
-
shape: Shape;
|
|
1274
|
-
}
|
|
1275
|
-
export interface $ZodPropertiesInternals<Shape extends $ZodShape = $ZodShape> extends $ZodTypeInternals<$InferObjectInput<Shape, {}>, $InferObjectInput<Shape, {}>>, checks.$ZodCheckInternals<{
|
|
1276
|
-
-readonly [k in keyof Shape]: util.Widen<core.input<Shape[k]>>;
|
|
1277
|
-
}> {
|
|
1278
|
-
def: $ZodPropertiesDef<Shape>;
|
|
1279
|
-
isst: errors.$ZodIssueInvalidType;
|
|
1280
|
-
issc: errors.$ZodIssue;
|
|
1281
|
-
}
|
|
1282
|
-
export interface $ZodProperties<Shape extends $ZodShape = $ZodShape> extends $ZodType {
|
|
1283
|
-
_zod: $ZodPropertiesInternals<Shape>;
|
|
1284
|
-
[Symbol.iterator](): Iterator<this>;
|
|
1285
|
-
}
|
|
1286
|
-
export declare const $ZodProperties: core.$constructor<$ZodProperties>;
|
|
1287
|
-
export type $ZodTypes = $ZodString | $ZodNumber | $ZodBigInt | $ZodBoolean | $ZodDate | $ZodSymbol | $ZodUndefined | $ZodNullable | $ZodNull | $ZodAny | $ZodUnknown | $ZodNever | $ZodVoid | $ZodArray | $ZodObject | $ZodUnion | $ZodIntersection | $ZodTuple | $ZodRecord | $ZodMap | $ZodSet | $ZodLiteral | $ZodEnum | $ZodFunction | $ZodPromise | $ZodLazy | $ZodOptional | $ZodDefault | $ZodPrefault | $ZodTemplateLiteral | $ZodCustom | $ZodProperties | $ZodTransform | $ZodNonOptional | $ZodReadonly | $ZodNaN | $ZodPipe | $ZodSuccess | $ZodCatch | $ZodFile;
|
|
1288
|
-
export type $ZodStringFormatTypes = $ZodGUID | $ZodUUID | $ZodEmail | $ZodURL | $ZodEmoji | $ZodNanoID | $ZodCUID | $ZodCUID2 | $ZodULID | $ZodXID | $ZodKSUID | $ZodISODateTime | $ZodISODate | $ZodISOTime | $ZodISODuration | $ZodIPv4 | $ZodIPv6 | $ZodMAC | $ZodCIDRv4 | $ZodCIDRv6 | $ZodBase64 | $ZodBase64URL | $ZodE164 | $ZodCreditCard | $ZodIBAN | $ZodJWT | $ZodCustomStringFormat<"hex"> | $ZodCustomStringFormat<util.HashFormat> | $ZodCustomStringFormat<"hostname">;
|
|
1272
|
+
export type $ZodTypes = $ZodString | $ZodNumber | $ZodBigInt | $ZodBoolean | $ZodDate | $ZodSymbol | $ZodUndefined | $ZodNullable | $ZodNull | $ZodAny | $ZodUnknown | $ZodNever | $ZodVoid | $ZodArray | $ZodObject | $ZodUnion | $ZodIntersection | $ZodTuple | $ZodRecord | $ZodMap | $ZodSet | $ZodLiteral | $ZodEnum | $ZodFunction | $ZodPromise | $ZodLazy | $ZodOptional | $ZodDefault | $ZodPrefault | $ZodTemplateLiteral | $ZodCustom | $ZodTransform | $ZodNonOptional | $ZodReadonly | $ZodNaN | $ZodPipe | $ZodSuccess | $ZodCatch | $ZodFile;
|
|
1273
|
+
export type $ZodStringFormatTypes = $ZodGUID | $ZodUUID | $ZodEmail | $ZodURL | $ZodEmoji | $ZodNanoID | $ZodCUID | $ZodCUID2 | $ZodULID | $ZodXID | $ZodKSUID | $ZodISODateTime | $ZodISODate | $ZodISOTime | $ZodISODuration | $ZodIPv4 | $ZodIPv6 | $ZodMAC | $ZodCIDRv4 | $ZodCIDRv6 | $ZodBase64 | $ZodBase64URL | $ZodE164 | $ZodCreditCard | $ZodIBAN | $ZodJWT | $ZodCustomStringFormat<"hex"> | $ZodCustomStringFormat<util.HashFormat> | $ZodCustomStringFormat<"hostname"> | $ZodCustomStringFormat<"currency_code">;
|