@gati-framework/types
Version:
Gati Type System - TypeScript-first branded types and schema system
81 lines • 2.04 kB
TypeScript
/**
* @module registry
* @description Brand validator registry for runtime validation
*/
/**
* Brand validator interface
* Validators MUST be synchronous - async validation should use middleware
*/
export interface BrandValidator {
/**
* Unique brand name (e.g., 'email', 'uuid')
*/
name: string;
/**
* Synchronous validation function
* Returns true if value is valid for this brand
*/
validate: (value: unknown) => boolean;
/**
* Must be false or undefined - async validators are not supported in MVP
*/
async?: false;
/**
* Optional description for documentation
*/
description?: string;
}
/**
* Brand validator registry singleton
* Manages runtime validators for branded types
*/
declare class BrandRegistryImpl {
private validators;
/**
* Register a brand validator
*
* @throws {Error} If validator is async
* @throws {Error} If brand name already registered
*
* @example
* ```typescript
* BrandRegistry.register({
* name: 'email',
* validate: (v) => typeof v === 'string' && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(v),
* description: 'RFC 5322 email format'
* });
* ```
*/
register(validator: BrandValidator): void;
/**
* Get a brand validator by name
*
* @param name - Brand name
* @returns Validator or undefined if not found
*/
get(name: string): BrandValidator | undefined;
/**
* Get all registered brand validators
*
* @returns Array of all validators
*/
getAll(): BrandValidator[];
/**
* Clear all registered validators (for testing)
* @internal
*/
clear(): void;
/**
* Check if a brand is registered
*
* @param name - Brand name
* @returns True if brand is registered
*/
has(name: string): boolean;
}
/**
* Global brand validator registry
*/
export declare const BrandRegistry: BrandRegistryImpl;
export {};
//# sourceMappingURL=registry.d.ts.map