64 lines
3.2 KiB
TypeScript
64 lines
3.2 KiB
TypeScript
import { Request, Response, NextFunction } from 'express';
|
|
/**
|
|
* Common validation middleware functions for request validation
|
|
*/
|
|
export declare class ValidationMiddleware {
|
|
/**
|
|
* Validates required fields in request body
|
|
* @param requiredFields Array of required field names
|
|
*/
|
|
static validateRequiredFields(requiredFields: string[]): (req: Request, res: Response, next: NextFunction) => Response<any, Record<string, any>> | undefined;
|
|
/**
|
|
* Validates field types in request body
|
|
* @param fieldTypes Object mapping field names to expected types
|
|
*/
|
|
static validateFieldTypes(fieldTypes: Record<string, 'string' | 'number' | 'boolean' | 'array' | 'object'>): (req: Request, res: Response, next: NextFunction) => Response<any, Record<string, any>> | undefined;
|
|
/**
|
|
* Validates string field length constraints
|
|
* @param constraints Object mapping field names to min/max length
|
|
*/
|
|
static validateStringLength(constraints: Record<string, {
|
|
min?: number;
|
|
max?: number;
|
|
}>): (req: Request, res: Response, next: NextFunction) => Response<any, Record<string, any>> | undefined;
|
|
/**
|
|
* Validates email format
|
|
* @param emailFields Array of field names that should contain valid emails
|
|
*/
|
|
static validateEmailFormat(emailFields: string[]): (req: Request, res: Response, next: NextFunction) => Response<any, Record<string, any>> | undefined;
|
|
/**
|
|
* Validates UUIDs format
|
|
* @param uuidFields Array of field names that should contain valid UUIDs
|
|
*/
|
|
static validateUUIDFormat(uuidFields: string[]): (req: Request, res: Response, next: NextFunction) => Response<any, Record<string, any>> | undefined;
|
|
/**
|
|
* Validates numeric constraints
|
|
* @param constraints Object mapping field names to min/max values
|
|
*/
|
|
static validateNumericConstraints(constraints: Record<string, {
|
|
min?: number;
|
|
max?: number;
|
|
}>): (req: Request, res: Response, next: NextFunction) => Response<any, Record<string, any>> | undefined;
|
|
/**
|
|
* Validates that arrays are not empty
|
|
* @param arrayFields Array of field names that should contain non-empty arrays
|
|
*/
|
|
static validateNonEmptyArrays(arrayFields: string[]): (req: Request, res: Response, next: NextFunction) => Response<any, Record<string, any>> | undefined;
|
|
/**
|
|
* Validates allowed values for enum-like fields
|
|
* @param allowedValues Object mapping field names to arrays of allowed values
|
|
*/
|
|
static validateAllowedValues(allowedValues: Record<string, any[]>): (req: Request, res: Response, next: NextFunction) => Response<any, Record<string, any>> | undefined;
|
|
/**
|
|
* Combines multiple validation middlewares
|
|
* @param validations Array of validation middleware functions
|
|
*/
|
|
static combine(validations: Array<(req: Request, res: Response, next: NextFunction) => void>): (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
/**
|
|
* Helper method to get nested values from request
|
|
* @param req Request object
|
|
* @param path Dot-notation path like 'body.user.id'
|
|
*/
|
|
private static getNestedValue;
|
|
}
|
|
//# sourceMappingURL=ValidationMiddleware.d.ts.map
|