import type { z } from 'zod'; import type { DefinitionIssue } from './definition-issue-types.js'; /** * A field-level issue checker result. * * The `path` is relative to the schema node the checker is registered on. * The infrastructure (`collectFieldIssues`) handles scoping to the correct * entity and prepending the entity-relative path. */ export type FieldIssueResult = Pick; /** * A field-level issue checker registered on a schema node. * Invoked during `collectFieldIssues()` to find problems in the local value. * * Returns issues with paths relative to the current schema node. * The infrastructure handles entity scoping automatically. */ export type DefinitionFieldIssueChecker = (value: T) => FieldIssueResult[]; /** * Metadata stored on a schema node annotated by `withIssueChecker`. * Exposed as readonly; the registry manages mutation internally. */ export interface FieldIssueCheckerSchemaMeta { readonly checkers: readonly DefinitionFieldIssueChecker[]; } /** * Registry that stores field-level issue checker metadata on Zod schema instances. * * Uses a WeakMap to avoid interfering with Zod's type system. * Annotated by `withIssueChecker()`; read by `collectFieldIssues()`. */ export declare const definitionFieldIssueRegistry: { add(schema: z.ZodType, checker: DefinitionFieldIssueChecker): void; get(schema: z.ZodType): FieldIssueCheckerSchemaMeta | undefined; }; /** * Creates a schema decorator that registers a field-level issue checker. * * Used with `.apply()`: * ```typescript * z.object({ ... }).apply(withIssueChecker((value) => { * const issues: FieldIssueResult[] = []; * if (someCondition) { * issues.push({ message: '...', path: ['fieldName'], severity: 'error' }); * } * return issues; * })) * ``` * * @param checker - The issue checker function to register * @returns A function that decorates a schema with the checker */ export declare function withIssueChecker(checker: DefinitionFieldIssueChecker>): (schema: T) => T; //# sourceMappingURL=definition-issue-registry.d.ts.map