UEA-PRODEM
This commit is contained in:
+53
-29
@@ -41,6 +41,7 @@ exports.merge = merge;
|
||||
exports.partial = partial;
|
||||
exports.required = required;
|
||||
exports.aborted = aborted;
|
||||
exports.explicitlyAborted = explicitlyAborted;
|
||||
exports.prefixIssues = prefixIssues;
|
||||
exports.unwrapMessage = unwrapMessage;
|
||||
exports.finalizeIssue = finalizeIssue;
|
||||
@@ -55,6 +56,7 @@ exports.base64urlToUint8Array = base64urlToUint8Array;
|
||||
exports.uint8ArrayToBase64url = uint8ArrayToBase64url;
|
||||
exports.hexToUint8Array = hexToUint8Array;
|
||||
exports.uint8ArrayToHex = uint8ArrayToHex;
|
||||
const core_js_1 = require("./core.cjs");
|
||||
// functions
|
||||
function assertEqual(val) {
|
||||
return val;
|
||||
@@ -104,21 +106,15 @@ function cleanRegex(source) {
|
||||
return source.slice(start, end);
|
||||
}
|
||||
function floatSafeRemainder(val, step) {
|
||||
const valDecCount = (val.toString().split(".")[1] || "").length;
|
||||
const stepString = step.toString();
|
||||
let stepDecCount = (stepString.split(".")[1] || "").length;
|
||||
if (stepDecCount === 0 && /\d?e-\d?/.test(stepString)) {
|
||||
const match = stepString.match(/\d?e-(\d?)/);
|
||||
if (match?.[1]) {
|
||||
stepDecCount = Number.parseInt(match[1]);
|
||||
}
|
||||
}
|
||||
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
||||
const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
|
||||
const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
|
||||
return (valInt % stepInt) / 10 ** decCount;
|
||||
const ratio = val / step;
|
||||
const roundedRatio = Math.round(ratio);
|
||||
// Use a relative epsilon scaled to the magnitude of the result
|
||||
const tolerance = Number.EPSILON * Math.max(Math.abs(ratio), 1);
|
||||
if (Math.abs(ratio - roundedRatio) < tolerance)
|
||||
return 0;
|
||||
return ratio - roundedRatio;
|
||||
}
|
||||
const EVALUATING = Symbol("evaluating");
|
||||
const EVALUATING = /* @__PURE__*/ Symbol("evaluating");
|
||||
function defineLazy(object, key, getter) {
|
||||
let value = undefined;
|
||||
Object.defineProperty(object, key, {
|
||||
@@ -205,6 +201,11 @@ function isObject(data) {
|
||||
return typeof data === "object" && data !== null && !Array.isArray(data);
|
||||
}
|
||||
exports.allowsEval = cached(() => {
|
||||
// Skip the probe under `jitless`: strict CSPs report the caught `new Function`
|
||||
// as a `securitypolicyviolation` even though the throw is swallowed.
|
||||
if (core_js_1.globalConfig.jitless) {
|
||||
return false;
|
||||
}
|
||||
// @ts-ignore
|
||||
if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) {
|
||||
return false;
|
||||
@@ -242,6 +243,10 @@ function shallowClone(o) {
|
||||
return { ...o };
|
||||
if (Array.isArray(o))
|
||||
return [...o];
|
||||
if (o instanceof Map)
|
||||
return new Map(o);
|
||||
if (o instanceof Set)
|
||||
return new Set(o);
|
||||
return o;
|
||||
}
|
||||
function numKeys(data) {
|
||||
@@ -300,7 +305,14 @@ const getParsedType = (data) => {
|
||||
};
|
||||
exports.getParsedType = getParsedType;
|
||||
exports.propertyKeyTypes = new Set(["string", "number", "symbol"]);
|
||||
exports.primitiveTypes = new Set(["string", "number", "bigint", "boolean", "symbol", "undefined"]);
|
||||
exports.primitiveTypes = new Set([
|
||||
"string",
|
||||
"number",
|
||||
"bigint",
|
||||
"boolean",
|
||||
"symbol",
|
||||
"undefined",
|
||||
]);
|
||||
function escapeRegex(str) {
|
||||
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||
}
|
||||
@@ -472,6 +484,9 @@ function safeExtend(schema, shape) {
|
||||
return clone(schema, def);
|
||||
}
|
||||
function merge(a, b) {
|
||||
if (a._zod.def.checks?.length) {
|
||||
throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
|
||||
}
|
||||
const def = mergeDefs(a._zod.def, {
|
||||
get shape() {
|
||||
const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
|
||||
@@ -481,7 +496,7 @@ function merge(a, b) {
|
||||
get catchall() {
|
||||
return b._zod.def.catchall;
|
||||
},
|
||||
checks: [], // delete existing checks
|
||||
checks: b._zod.def.checks ?? [],
|
||||
});
|
||||
return clone(a, def);
|
||||
}
|
||||
@@ -575,6 +590,18 @@ function aborted(x, startIndex = 0) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// Checks for explicit abort (continue === false), as opposed to implicit abort (continue === undefined).
|
||||
// Used to respect `abort: true` in .refine() even for checks that have a `when` function.
|
||||
function explicitlyAborted(x, startIndex = 0) {
|
||||
if (x.aborted === true)
|
||||
return true;
|
||||
for (let i = startIndex; i < x.issues.length; i++) {
|
||||
if (x.issues[i]?.continue === false) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function prefixIssues(path, issues) {
|
||||
return issues.map((iss) => {
|
||||
var _a;
|
||||
@@ -587,23 +614,20 @@ function unwrapMessage(message) {
|
||||
return typeof message === "string" ? message : message?.message;
|
||||
}
|
||||
function finalizeIssue(iss, ctx, config) {
|
||||
const full = { ...iss, path: iss.path ?? [] };
|
||||
// for backwards compatibility
|
||||
if (!iss.message) {
|
||||
const message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ??
|
||||
const message = iss.message
|
||||
? iss.message
|
||||
: (unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ??
|
||||
unwrapMessage(ctx?.error?.(iss)) ??
|
||||
unwrapMessage(config.customError?.(iss)) ??
|
||||
unwrapMessage(config.localeError?.(iss)) ??
|
||||
"Invalid input";
|
||||
full.message = message;
|
||||
"Invalid input");
|
||||
const { inst: _inst, continue: _continue, input: _input, ...rest } = iss;
|
||||
rest.path ?? (rest.path = []);
|
||||
rest.message = message;
|
||||
if (ctx?.reportInput) {
|
||||
rest.input = _input;
|
||||
}
|
||||
// delete (full as any).def;
|
||||
delete full.inst;
|
||||
delete full.continue;
|
||||
if (!ctx?.reportInput) {
|
||||
delete full.input;
|
||||
}
|
||||
return full;
|
||||
return rest;
|
||||
}
|
||||
function getSizableOrigin(input) {
|
||||
if (input instanceof Set)
|
||||
|
||||
Reference in New Issue
Block a user