@t3-oss/env-core
Version:
 [](https://jsr.io/@t3-oss/env-core) [](https://jsr.io/@t3-oss/env-core) [![Socket Bad
27 lines (26 loc) • 816 B
JavaScript
//#region src/standard.ts
function ensureSynchronous(value, message) {
if (value instanceof Promise) throw new Error(message);
}
function parseWithDictionary(dictionary, value) {
const result = {};
const issues = [];
for (const key in dictionary) {
const propResult = dictionary[key]["~standard"].validate(value[key]);
ensureSynchronous(propResult, `Validation must be synchronous, but ${key} returned a Promise.`);
if (propResult.issues) {
issues.push(...propResult.issues.map((issue) => ({
...issue,
message: issue.message,
path: [key, ...issue.path ?? []]
})));
continue;
}
result[key] = propResult.value;
}
if (issues.length) return { issues };
return { value: result };
}
//#endregion
export { ensureSynchronous, parseWithDictionary };
//# sourceMappingURL=standard.js.map