UNPKG

@oxyhq/services

Version:

Reusable OxyHQ module to handle authentication, user management, karma system, device-based session management and more 🚀

86 lines • 2.44 kB
/** * Validation utilities for common data validation patterns */ /** * Email validation regex */ export declare const EMAIL_REGEX: RegExp; /** * Username validation regex (alphanumeric, underscores, and hyphens, 3-30 chars) */ export declare const USERNAME_REGEX: RegExp; /** * Password validation regex (at least 8 chars, 1 uppercase, 1 lowercase, 1 number) */ export declare const PASSWORD_REGEX: RegExp; /** * Validate email format */ export declare function isValidEmail(email: string): boolean; /** * Validate username format */ export declare function isValidUsername(username: string): boolean; /** * Validate password strength */ export declare function isValidPassword(password: string): boolean; /** * Validate required string */ export declare function isRequiredString(value: unknown): boolean; /** * Validate required number */ export declare function isRequiredNumber(value: unknown): boolean; /** * Validate required boolean */ export declare function isRequiredBoolean(value: unknown): boolean; /** * Validate array */ export declare function isValidArray(value: unknown): boolean; /** * Validate object */ export declare function isValidObject(value: unknown): boolean; /** * Validate UUID format */ export declare function isValidUUID(uuid: string): boolean; /** * Validate URL format */ export declare function isValidURL(url: string): boolean; /** * Validate date string */ export declare function isValidDate(dateString: string): boolean; /** * Validate file size (in bytes) */ export declare function isValidFileSize(size: number, maxSize: number): boolean; /** * Validate file type */ export declare function isValidFileType(filename: string, allowedTypes: string[]): boolean; /** * Sanitize string input */ export declare function sanitizeString(input: string): string; /** * Sanitize HTML input */ export declare function sanitizeHTML(input: string): string; /** * Validate MongoDB ObjectId format * Note: This is a basic format check. For full validation, use mongoose.Types.ObjectId.isValid() * This function works in environments where mongoose may not be available (e.g., client-side) */ export declare function isValidObjectId(id: string): boolean; /** * Validate and sanitize user input */ export declare function validateAndSanitizeUserInput(input: unknown, type: 'string' | 'email' | 'username'): string | null; //# sourceMappingURL=validationUtils.d.ts.map