UNPKG

@nasriya/atomix

Version:

Composable helper functions for building reliable systems

60 lines (59 loc) 2.23 kB
import { FileExtension, Mime } from "./mimes/mimes"; declare class HTTPGuard { /** * Checks if the provided value is a valid HTML string. * * @param value - The value to check. * @returns True if the value is a valid HTML string, otherwise false. * @since v1.0.0 * @description * A valid HTML string is a string that contains at least one HTML tag. * The HTML tags are matched using a regex pattern. */ isHTML(value: string): value is string; /** * Checks if the provided value is a valid MIME type. * * @param value - The value to check. * @returns True if the value is a valid MIME type, otherwise false. * @since v1.0.0 * @description * A valid MIME type is a string that matches one of the predefined MIME types. */ isMimeType(value: unknown): value is Mime; /** * Checks if the provided value is a valid file extension. * * @param value - The value to check. * @returns True if the value is a valid file extension, otherwise false. * @since v1.0.0 * @description * A valid file extension is a string that matches one of the predefined file extensions. */ isExtension(value: unknown): value is FileExtension; /** * Checks if the provided value is a valid URL. * * @param url - The value to check. * @returns True if the value is a valid URL, otherwise false. * @since v1.0.0 * @description * The URL is validated by attempting to create a new URL object * with the provided value. If the value is not a valid URL, the * constructor will throw an error. */ isValidURL(url: unknown): boolean; /** * Checks if the provided value is a valid email address. * * @param value - The value to check. * @returns True if the value is a valid email address, otherwise false. * @since v1.0.0 * @description * The email address is validated by attempting to match it against a regular * expression. The regular expression is in the format of `/^[^\s@]+@[^\s@]+\.[^\s@]+$/i`. */ isEmail(value: unknown): value is string; } declare const httpGuard: HTTPGuard; export default httpGuard;