/** * @module validators/make-validator * @description Factory for creating custom validators with reusable base * options, validation functions, transforms, or schema factories. */ import { z } from "zod/v4"; import type { BaseOptions, CustomValidatorOptions } from "../types.js"; /** * Create a custom validator with factory pattern. * Returns a function that can be called with option overrides. * * @param baseOptions - Base options for all uses of this validator * @returns Factory function that creates validators with merged options * * @example * Custom validator with validation function * ```ts * const semver = makeValidator({ * validator: (input) => /^\d+\.\d+\.\d+$/.test(input), * description: 'Semantic version string' * }); * * const env = zenv({ * APP_VERSION: semver({ default: '1.0.0' }) * }); * ``` * * @example * Custom validator with transform * ```ts * const secret = makeValidator({ * validator: (input) => Buffer.from(input, 'base64').length === 32, * transform: (input) => Buffer.from(input, 'base64'), * description: '32-byte secret key' * }); * * const env = zenv({ * ENCRYPTION_KEY: secret() * }); * ``` * * @example * Custom validator with Zod schema factory * ```ts * const jsonArray = makeValidator({ * schemaFactory: () => z.string().transform(val => JSON.parse(val)), * description: 'JSON array of strings' * }); * * const env = zenv({ * ALLOWED_ORIGINS: jsonArray({ default: '["http://localhost:3000"]' }) * }); * ``` */ export declare function makeValidator(baseOptions: CustomValidatorOptions): (overrides?: BaseOptions) => z.ZodType;