gitea push
This commit is contained in:
+41
-4
@@ -112,6 +112,7 @@ exports.catch = _catch;
|
||||
exports.nan = nan;
|
||||
exports.pipe = pipe;
|
||||
exports.codec = codec;
|
||||
exports.invertCodec = invertCodec;
|
||||
exports.readonly = readonly;
|
||||
exports.templateLiteral = templateLiteral;
|
||||
exports.lazy = _lazy;
|
||||
@@ -144,7 +145,11 @@ exports.ZodMiniType = core.$constructor("ZodMiniType", (inst, def) => {
|
||||
...def,
|
||||
checks: [
|
||||
...(def.checks ?? []),
|
||||
...checks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch),
|
||||
...checks.map((ch) => typeof ch === "function"
|
||||
? {
|
||||
_zod: { check: ch, def: { check: "custom" }, onattach: [] },
|
||||
}
|
||||
: ch),
|
||||
],
|
||||
}, { parent: true });
|
||||
};
|
||||
@@ -218,7 +223,7 @@ function url(params) {
|
||||
// @__NO_SIDE_EFFECTS__
|
||||
function httpUrl(params) {
|
||||
return core._url(exports.ZodMiniURL, {
|
||||
protocol: /^https?$/,
|
||||
protocol: core.regexes.httpProtocol,
|
||||
hostname: core.regexes.domain,
|
||||
...util.normalizeParams(params),
|
||||
});
|
||||
@@ -239,10 +244,22 @@ exports.ZodMiniNanoID = core.$constructor("ZodMiniNanoID", (inst, def) => {
|
||||
function nanoid(params) {
|
||||
return core._nanoid(exports.ZodMiniNanoID, params);
|
||||
}
|
||||
/**
|
||||
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
||||
* (timestamps embedded in the id). Use {@link ZodMiniCUID2} instead.
|
||||
* See https://github.com/paralleldrive/cuid.
|
||||
*/
|
||||
exports.ZodMiniCUID = core.$constructor("ZodMiniCUID", (inst, def) => {
|
||||
core.$ZodCUID.init(inst, def);
|
||||
exports.ZodMiniStringFormat.init(inst, def);
|
||||
});
|
||||
/**
|
||||
* Validates a CUID v1 string.
|
||||
*
|
||||
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
||||
* (timestamps embedded in the id). Use {@link cuid2 | `z.cuid2()`} instead.
|
||||
* See https://github.com/paralleldrive/cuid.
|
||||
*/
|
||||
// @__NO_SIDE_EFFECTS__
|
||||
function cuid(params) {
|
||||
return core._cuid(exports.ZodMiniCUID, params);
|
||||
@@ -668,6 +685,15 @@ exports.ZodMiniRecord = core.$constructor("ZodMiniRecord", (inst, def) => {
|
||||
});
|
||||
// @__NO_SIDE_EFFECTS__
|
||||
function record(keyType, valueType, params) {
|
||||
// v3-compat: z.record(valueType, params?) — defaults keyType to z.string()
|
||||
if (!valueType || !valueType._zod) {
|
||||
return new exports.ZodMiniRecord({
|
||||
type: "record",
|
||||
keyType: string(),
|
||||
valueType: keyType,
|
||||
...util.normalizeParams(valueType),
|
||||
});
|
||||
}
|
||||
return new exports.ZodMiniRecord({
|
||||
type: "record",
|
||||
keyType,
|
||||
@@ -915,6 +941,17 @@ function codec(in_, out, params) {
|
||||
reverseTransform: params.encode,
|
||||
});
|
||||
}
|
||||
// @__NO_SIDE_EFFECTS__
|
||||
function invertCodec(codec) {
|
||||
const def = codec._zod.def;
|
||||
return new exports.ZodMiniCodec({
|
||||
type: "pipe",
|
||||
in: def.out,
|
||||
out: def.in,
|
||||
transform: def.reverseTransform,
|
||||
reverseTransform: def.transform,
|
||||
});
|
||||
}
|
||||
exports.ZodMiniReadonly = core.$constructor("ZodMiniReadonly", (inst, def) => {
|
||||
core.$ZodReadonly.init(inst, def);
|
||||
exports.ZodMiniType.init(inst, def);
|
||||
@@ -990,8 +1027,8 @@ function refine(fn, _params = {}) {
|
||||
}
|
||||
// superRefine
|
||||
// @__NO_SIDE_EFFECTS__
|
||||
function superRefine(fn) {
|
||||
return core._superRefine(fn);
|
||||
function superRefine(fn, params) {
|
||||
return core._superRefine(fn, params);
|
||||
}
|
||||
// Re-export describe and meta from core
|
||||
exports.describe = core.describe;
|
||||
|
||||
Reference in New Issue
Block a user