UNPKG

@t3-oss/env-core

Version:

![NPM Version](https://img.shields.io/npm/v/%40t3-oss%2Fenv-core) [![JSR](https://jsr.io/badges/@t3-oss/env-core)](https://jsr.io/@t3-oss/env-core) [![JSR Score](https://jsr.io/badges/@t3-oss/env-core/score)](https://jsr.io/@t3-oss/env-core) [![Socket Bad

27 lines (26 loc) 816 B
//#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