/** * Shared Validation Schema Patterns * * Provides common validation schemas and patterns to reduce duplication * across the qtests codebase. Centralizes validation rules, * sanitization functions, and schema composition utilities. */ import { z } from 'zod'; export declare const basicSchemas: { safeString: z.ZodEffects; safeNumber: z.ZodNumber; safeBoolean: z.ZodBoolean; safeArray: z.ZodArray; safeObject: z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>; shortString: z.ZodEffects; mediumString: z.ZodEffects; longString: z.ZodEffects; identifier: z.ZodEffects; email: z.ZodEffects; url: z.ZodEffects; path: z.ZodEffects; json: z.ZodEffects, string, string>; port: z.ZodNumber; percentage: z.ZodNumber; positiveInt: z.ZodNumber; nonNegativeInt: z.ZodNumber; timestamp: z.ZodNumber; duration: z.ZodNumber; timeout: z.ZodNumber; rateLimit: z.ZodNumber; memorySize: z.ZodNumber; memoryMB: z.ZodNumber; securityLevel: z.ZodEnum<["low", "medium", "high", "critical"]>; eventType: z.ZodString; moduleName: z.ZodEffects; }; export declare const objectSchemas: { apiResponse: z.ZodObject<{ success: z.ZodBoolean; data: z.ZodOptional; error: z.ZodOptional; timestamp: z.ZodOptional; requestId: z.ZodOptional; }, "strip", z.ZodTypeAny, { success: boolean; error?: string | undefined; timestamp?: number | undefined; data?: any; requestId?: string | undefined; }, { success: boolean; error?: string | undefined; timestamp?: number | undefined; data?: any; requestId?: string | undefined; }>; pagination: z.ZodObject<{ page: z.ZodDefault; limit: z.ZodDefault; total: z.ZodOptional; hasNext: z.ZodOptional; }, "strip", z.ZodTypeAny, { limit: number; page: number; total?: number | undefined; hasNext?: boolean | undefined; }, { limit?: number | undefined; page?: number | undefined; total?: number | undefined; hasNext?: boolean | undefined; }>; searchQuery: z.ZodObject<{ query: z.ZodOptional>; filters: z.ZodOptional>; sort: z.ZodOptional>; page: z.ZodDefault; limit: z.ZodDefault; }, "strip", z.ZodTypeAny, { limit: number; page: number; sort?: Record | undefined; query?: string | undefined; filters?: Record | undefined; }, { sort?: Record | undefined; query?: string | undefined; limit?: number | undefined; page?: number | undefined; filters?: Record | undefined; }>; memorySnapshot: z.ZodObject<{ timestamp: z.ZodNumber; heapUsed: z.ZodNumber; heapTotal: z.ZodNumber; rss: z.ZodNumber; external: z.ZodNumber; }, "strip", z.ZodTypeAny, { timestamp: number; heapUsed: number; heapTotal: number; rss: number; external: number; }, { timestamp: number; heapUsed: number; heapTotal: number; rss: number; external: number; }>; securityEvent: z.ZodObject<{ id: z.ZodEffects; timestamp: z.ZodNumber; type: z.ZodString; severity: z.ZodEnum<["low", "medium", "high", "critical"]>; source: z.ZodEffects; details: z.ZodRecord; blocked: z.ZodBoolean; remediation: z.ZodEffects; }, "strip", z.ZodTypeAny, { timestamp: number; type: string; id: string; severity: "critical" | "medium" | "low" | "high"; source: string; details: Record; blocked: boolean; remediation: string; }, { timestamp: number; type: string; id: string; severity: "critical" | "medium" | "low" | "high"; source: string; details: Record; blocked: boolean; remediation: string; }>; serverConfig: z.ZodObject<{ port: z.ZodDefault; host: z.ZodDefault>; timeout: z.ZodDefault; cors: z.ZodDefault; https: z.ZodDefault; }, "strip", z.ZodTypeAny, { timeout: number; https: boolean; host: string; port: number; cors: boolean; }, { timeout?: number | undefined; https?: boolean | undefined; host?: string | undefined; port?: number | undefined; cors?: boolean | undefined; }>; testConfig: z.ZodObject<{ testName: z.ZodEffects; timeout: z.ZodDefault; retries: z.ZodDefault; parallel: z.ZodDefault; verbose: z.ZodDefault; }, "strip", z.ZodTypeAny, { timeout: number; testName: string; verbose: boolean; retries: number; parallel: boolean; }, { testName: string; timeout?: number | undefined; verbose?: boolean | undefined; retries?: number | undefined; parallel?: boolean | undefined; }>; validationConfig: z.ZodObject<{ maxStringLength: z.ZodDefault; maxArrayLength: z.ZodDefault; maxObjectDepth: z.ZodDefault; sanitizeInput: z.ZodDefault; strictMode: z.ZodDefault; }, "strip", z.ZodTypeAny, { maxArrayLength: number; maxStringLength: number; maxObjectDepth: number; sanitizeInput: boolean; strictMode: boolean; }, { maxArrayLength?: number | undefined; maxStringLength?: number | undefined; maxObjectDepth?: number | undefined; sanitizeInput?: boolean | undefined; strictMode?: boolean | undefined; }>; }; export declare const securitySchemas: { safeInput: z.ZodEffects, string, string>, string, string>, string, string>; moduleId: z.ZodEffects, string, string>; filePath: z.ZodEffects, string, string>, string, string>; command: z.ZodEffects; envVar: z.ZodEffects; jsonContent: z.ZodEffects, string, string>; }; export declare const schemaUtils: { /** * Create a schema with optional fields made optional */ optionalize: (schema: z.ZodObject) => z.ZodObject<{ [x: string]: z.ZodOptional; }, z.UnknownKeysParam, z.ZodTypeAny, { [x: string]: any; }, { [x: string]: any; }>; /** * Create a schema with required fields */ require: (schema: z.ZodObject) => z.ZodObject; /** * Merge multiple schemas */ merge: (base: z.ZodObject, extension: z.ZodObject) => z.ZodObject<{} & { [x: string]: any; }, z.UnknownKeysParam, z.ZodTypeAny, { [x: string]: any; }, { [x: string]: any; }>; /** * Add validation rules to an existing schema */ withValidation: (schema: z.ZodTypeAny, rules: Array<{ refine: (val: any) => boolean; message: string; }>) => z.ZodTypeAny; /** * Create a schema with default transformation */ withTransform: (schema: z.ZodTypeAny, transform: (val: any) => any) => z.ZodEffects; /** * Add custom error messages to a schema */ withErrors: (schema: z.ZodTypeAny, errors: Record) => z.ZodTypeAny; }; export declare const validationHelpers: { /** * Validate data with comprehensive error handling */ validateWithErrors: (schema: z.ZodSchema, data: unknown, context?: string) => { success: boolean; data?: T; errors?: string[]; }; /** * Validate async data */ validateAsync: (schema: z.ZodSchema, data: unknown, context?: string) => Promise<{ success: boolean; data?: T; errors?: string[]; }>; /** * Create validation middleware */ createValidator: (schema: z.ZodSchema, context?: string) => (data: unknown) => T; }; export { z }; export declare const schemas: { basic: { safeString: z.ZodEffects; safeNumber: z.ZodNumber; safeBoolean: z.ZodBoolean; safeArray: z.ZodArray; safeObject: z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>; shortString: z.ZodEffects; mediumString: z.ZodEffects; longString: z.ZodEffects; identifier: z.ZodEffects; email: z.ZodEffects; url: z.ZodEffects; path: z.ZodEffects; json: z.ZodEffects, string, string>; port: z.ZodNumber; percentage: z.ZodNumber; positiveInt: z.ZodNumber; nonNegativeInt: z.ZodNumber; timestamp: z.ZodNumber; duration: z.ZodNumber; timeout: z.ZodNumber; rateLimit: z.ZodNumber; memorySize: z.ZodNumber; memoryMB: z.ZodNumber; securityLevel: z.ZodEnum<["low", "medium", "high", "critical"]>; eventType: z.ZodString; moduleName: z.ZodEffects; }; objects: { apiResponse: z.ZodObject<{ success: z.ZodBoolean; data: z.ZodOptional; error: z.ZodOptional; timestamp: z.ZodOptional; requestId: z.ZodOptional; }, "strip", z.ZodTypeAny, { success: boolean; error?: string | undefined; timestamp?: number | undefined; data?: any; requestId?: string | undefined; }, { success: boolean; error?: string | undefined; timestamp?: number | undefined; data?: any; requestId?: string | undefined; }>; pagination: z.ZodObject<{ page: z.ZodDefault; limit: z.ZodDefault; total: z.ZodOptional; hasNext: z.ZodOptional; }, "strip", z.ZodTypeAny, { limit: number; page: number; total?: number | undefined; hasNext?: boolean | undefined; }, { limit?: number | undefined; page?: number | undefined; total?: number | undefined; hasNext?: boolean | undefined; }>; searchQuery: z.ZodObject<{ query: z.ZodOptional>; filters: z.ZodOptional>; sort: z.ZodOptional>; page: z.ZodDefault; limit: z.ZodDefault; }, "strip", z.ZodTypeAny, { limit: number; page: number; sort?: Record | undefined; query?: string | undefined; filters?: Record | undefined; }, { sort?: Record | undefined; query?: string | undefined; limit?: number | undefined; page?: number | undefined; filters?: Record | undefined; }>; memorySnapshot: z.ZodObject<{ timestamp: z.ZodNumber; heapUsed: z.ZodNumber; heapTotal: z.ZodNumber; rss: z.ZodNumber; external: z.ZodNumber; }, "strip", z.ZodTypeAny, { timestamp: number; heapUsed: number; heapTotal: number; rss: number; external: number; }, { timestamp: number; heapUsed: number; heapTotal: number; rss: number; external: number; }>; securityEvent: z.ZodObject<{ id: z.ZodEffects; timestamp: z.ZodNumber; type: z.ZodString; severity: z.ZodEnum<["low", "medium", "high", "critical"]>; source: z.ZodEffects; details: z.ZodRecord; blocked: z.ZodBoolean; remediation: z.ZodEffects; }, "strip", z.ZodTypeAny, { timestamp: number; type: string; id: string; severity: "critical" | "medium" | "low" | "high"; source: string; details: Record; blocked: boolean; remediation: string; }, { timestamp: number; type: string; id: string; severity: "critical" | "medium" | "low" | "high"; source: string; details: Record; blocked: boolean; remediation: string; }>; serverConfig: z.ZodObject<{ port: z.ZodDefault; host: z.ZodDefault>; timeout: z.ZodDefault; cors: z.ZodDefault; https: z.ZodDefault; }, "strip", z.ZodTypeAny, { timeout: number; https: boolean; host: string; port: number; cors: boolean; }, { timeout?: number | undefined; https?: boolean | undefined; host?: string | undefined; port?: number | undefined; cors?: boolean | undefined; }>; testConfig: z.ZodObject<{ testName: z.ZodEffects; timeout: z.ZodDefault; retries: z.ZodDefault; parallel: z.ZodDefault; verbose: z.ZodDefault; }, "strip", z.ZodTypeAny, { timeout: number; testName: string; verbose: boolean; retries: number; parallel: boolean; }, { testName: string; timeout?: number | undefined; verbose?: boolean | undefined; retries?: number | undefined; parallel?: boolean | undefined; }>; validationConfig: z.ZodObject<{ maxStringLength: z.ZodDefault; maxArrayLength: z.ZodDefault; maxObjectDepth: z.ZodDefault; sanitizeInput: z.ZodDefault; strictMode: z.ZodDefault; }, "strip", z.ZodTypeAny, { maxArrayLength: number; maxStringLength: number; maxObjectDepth: number; sanitizeInput: boolean; strictMode: boolean; }, { maxArrayLength?: number | undefined; maxStringLength?: number | undefined; maxObjectDepth?: number | undefined; sanitizeInput?: boolean | undefined; strictMode?: boolean | undefined; }>; }; security: { safeInput: z.ZodEffects, string, string>, string, string>, string, string>; moduleId: z.ZodEffects, string, string>; filePath: z.ZodEffects, string, string>, string, string>; command: z.ZodEffects; envVar: z.ZodEffects; jsonContent: z.ZodEffects, string, string>; }; utils: { /** * Create a schema with optional fields made optional */ optionalize: (schema: z.ZodObject) => z.ZodObject<{ [x: string]: z.ZodOptional; }, z.UnknownKeysParam, z.ZodTypeAny, { [x: string]: any; }, { [x: string]: any; }>; /** * Create a schema with required fields */ require: (schema: z.ZodObject) => z.ZodObject; /** * Merge multiple schemas */ merge: (base: z.ZodObject, extension: z.ZodObject) => z.ZodObject<{} & { [x: string]: any; }, z.UnknownKeysParam, z.ZodTypeAny, { [x: string]: any; }, { [x: string]: any; }>; /** * Add validation rules to an existing schema */ withValidation: (schema: z.ZodTypeAny, rules: Array<{ refine: (val: any) => boolean; message: string; }>) => z.ZodTypeAny; /** * Create a schema with default transformation */ withTransform: (schema: z.ZodTypeAny, transform: (val: any) => any) => z.ZodEffects; /** * Add custom error messages to a schema */ withErrors: (schema: z.ZodTypeAny, errors: Record) => z.ZodTypeAny; }; helpers: { /** * Validate data with comprehensive error handling */ validateWithErrors: (schema: z.ZodSchema, data: unknown, context?: string) => { success: boolean; data?: T; errors?: string[]; }; /** * Validate async data */ validateAsync: (schema: z.ZodSchema, data: unknown, context?: string) => Promise<{ success: boolean; data?: T; errors?: string[]; }>; /** * Create validation middleware */ createValidator: (schema: z.ZodSchema, context?: string) => (data: unknown) => T; }; }; //# sourceMappingURL=validationSchemas.d.ts.map