"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/index.ts var src_exports = {}; __export(src_exports, { EnveyValidationError: () => EnveyValidationError, bool: () => bool, createConfig: () => createConfig }); module.exports = __toCommonJS(src_exports); // src/errors.ts var EnveyValidationError = class extends Error { issues; constructor(issues, message) { super(message); this.name = "EnveyValidationError"; this.issues = issues; } }; // src/envey.ts function createConfig(zodInstance, schema, options) { const { validate } = options; const config = {}; const values = {}; for (const key in schema) { const field = schema[key]; config[key] = field.format; values[key] = field.env ? process.env[field.env] : void 0; } if (validate) { const validationResult = zodInstance.object(config).safeParse(values); if (!validationResult.success) { return { error: new EnveyValidationError( validationResult.error.issues, `Invalid configuration` ), success: false }; } return { config: validationResult.data, success: true }; } return { config: values, success: true }; } // src/helpers.ts function bool(zodInstance, defaultValue) { return zodInstance.enum(["true", "false", "1", "0", "TRUE", "FALSE"]).transform( (value) => value === "true" || value === "1" || value === "TRUE" ).default(defaultValue.toString()); } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { EnveyValidationError, bool, createConfig }); //# sourceMappingURL=index.cjs.map