UNPKG

go-meow

Version:

A modular microservice template built with TypeScript, Express, and Prisma (MongoDB). It includes service scaffolding tools, consistent query utilities with data grouping, Zod validation, structured logging, comprehensive seeding system, and Swagger/OpenA

66 lines 3.75 kB
import { ZodError } from "zod"; export interface ValidationResult { isValid: boolean; error?: string; } export declare const OBJECT_ID_REGEX: RegExp; export declare const EMAIL_REGEX: RegExp; export declare const URL_REGEX: RegExp; export declare const validateObjectId: (id: string, fieldName?: string) => ValidationResult; export declare const validateRequiredString: (value: any, fieldName: string) => ValidationResult; export declare const validateNumber: (value: any, fieldName: string, min?: number, max?: number) => ValidationResult; export declare const validatePositiveNumber: (value: any, fieldName: string) => ValidationResult; export declare const validateInteger: (value: any, fieldName: string, min?: number, max?: number) => ValidationResult; export declare const validateBoolean: (value: any, fieldName: string) => ValidationResult; export declare const validateEmail: (value: any, fieldName: string) => ValidationResult; export declare const validateUrl: (value: any, fieldName: string) => ValidationResult; export declare const validateEnum: (value: any, allowedValues: any[], fieldName: string) => ValidationResult; export declare const validateArray: (value: any, fieldName: string, minLength?: number, maxLength?: number) => ValidationResult; export declare const validateObjectIdArray: (value: any, fieldName: string) => ValidationResult; export declare const validateUrlArray: (value: any, fieldName: string) => ValidationResult; export declare const validateObject: (value: any, fieldName: string) => ValidationResult; export declare const validateStringLength: (value: any, fieldName: string, minLength?: number, maxLength?: number) => ValidationResult; export declare const validatePricing: (pricing: any) => ValidationResult; export declare const combineValidations: (...validations: ValidationResult[]) => ValidationResult; export declare const validateRequiredFields: (data: any, requiredFields: string[]) => ValidationResult; export declare const formatZodErrors: (error: ZodError) => { field: string; message: string; }[]; export declare const createValidationErrorResponse: (message: string, errors: any[]) => { status: string; message: string; errors: any[]; code: number; timestamp: string; }; export declare const createSuccessResponse: (message: string, data?: any) => any; export declare const createErrorResponse: (message: string, code?: string, errors?: any[]) => { code: string; timestamp: string; errors?: any[] | undefined; status: string; message: string; }; export declare const validateWithZod: <T>(schema: any, data: any) => { success: true; data: T; } | { success: false; error: any; }; export declare const sendValidationError: (res: any, message: string, errors: any[]) => any; export declare const sendSuccessResponse: (res: any, message: string, data?: any, statusCode?: number) => any; export declare const sendErrorResponse: (res: any, message: string, code?: string, errors?: any[], statusCode?: number) => any; export declare const sendNotFoundResponse: (res: any, resource: string, field?: string) => any; export declare const sendConflictResponse: (res: any, field: string, message: string) => any; export declare const sendUnauthorizedResponse: (res: any, message?: string) => any; export declare const sendForbiddenResponse: (res: any, message?: string) => any; export declare const sendQueryValidationError: (res: any, message: string, field?: string) => any; export declare const handlePrismaError: (error: any) => { message: string; code: string; statusCode: number; }; export declare const sendPrismaErrorResponse: (res: any, error: any, logger?: any) => any; //# sourceMappingURL=validationHelper.d.ts.map