UNPKG

@th3hero/request-validator

Version:

🚀 Lightweight, fast & flexible request validation library for Node.js/Express/Next.js with TypeScript support. Features 20+ validation rules, database integration, file upload validation, and zero external dependencies. Perfect for API validation, form v

21 lines (20 loc) • 667 B
import { Request } from 'express'; import { Pool } from 'mysql'; export interface ValidationRules { [key: string]: string | string[]; } export interface ValidationError { [key: string]: string; } export interface ValidationResult { failed: boolean; errors: ValidationError | null; } export interface ExtendedRequest extends Request { body: Record<string, any>; files?: Record<string, any>; customValidators?: Record<string, CustomValidator>; } export type CustomValidator = (value: any, req: ExtendedRequest) => boolean | string; export declare const setDatabase: (pool: Pool) => void; export declare const getDatabase: () => Pool | null;