//#region src/utils/validator.d.ts declare const validatorSymbol: unique symbol; type ValidationResult = { success: true; value: T; } | { success: false; error: E; }; interface Validator { [validatorSymbol]: true; /** * Validates that the structure of a value matches this schema, * and returns a typed version of the value if it does. */ readonly validate?: (value: unknown) => ValidationResult; } declare class TypeValidationError extends Error { readonly value: unknown; readonly cause?: unknown; constructor({ value, cause }: { value: unknown; cause?: unknown; }); } /** * Wraps a validation function as a `Validator`. * * @param validate A validation function for the schema */ declare function validator(validate?: ((value: unknown) => ValidationResult)): Validator; /** * Validates an unknown value against a schema and returns it strongly typed. * * @template T The type the value is validated against * @param value The value to validate * @param schema The schema to validate against */ declare function validateTypes({ value, schema: inputSchema }: { value: unknown; schema: Validator; }): T; /** * Validates an unknown value against a schema, reporting failure as a result * rather than as a thrown error. * * @template T The type the value is validated against * @param value The value to validate * @param schema The schema to validate against * @returns Either the typed value under a `success` flag, or the error that rejected it */ declare function safeValidateTypes({ value, schema }: { value: unknown; schema: Validator; }): ValidationResult; declare function isValidator(value: unknown): value is Validator; //#endregion export { TypeValidationError, ValidationResult, Validator, isValidator, safeValidateTypes, validateTypes, validator, validatorSymbol };