UNPKG

@cdwr/core

Version:

A set of core utilities for the Codeware ecosystem.

35 lines (34 loc) 825 B
import { z } from 'zod'; type Options = { /** * The string to match */ match: string; /** * The value to replace the matched string with */ value: string | number | undefined | null; /** * Whether to require a valid value to perform the replacement. * * Use this to prevent replacing an undefined value with empty string. * * @default false */ strict?: boolean; }; /** * A Zod preprocessor that replaces all occurrences of a string with a new value. * * @example * * ```ts * const schema = z.string(); * * const transformed = withReplaceAll(schema, { * match: 'foo', value: 'bar' * }); * ``` */ export declare const withReplaceAll: <T extends z.ZodType>(schema: T, options: Options) => z.ZodEffects<T, T["_output"], unknown>; export {};