UNPKG

multiform-validator

Version:

Javascript library made to validate, several form fields, such as: email, images, phone, password, cpf etc.

20 lines (19 loc) 906 B
type ImageMimeType = "gif" | "ico" | "jpeg" | "png"; interface OptionsParams { exclude: ImageMimeType[]; } /** * Checks if the given file buffer represents a valid image. * @param fileBuffer - The buffer containing the file data. * @description - This function checks the magic numbers of the file buffer to determine if it is a valid image. * @param options - An object containing the options for the function. * @param options.exclude - An array of image types to exclude from the validation. * * type ImageMimeType = "gif" | "ico" | "jpeg" | "png"; * * If you want to exclude some image types from the validation, you can pass the options * @example - isValidImage(fileBuffer, { exclude: ["gif", "ico"] }); * @returns A boolean indicating whether the file is a valid image or not. */ export default function isValidImage(fileBuffer: Buffer, options?: OptionsParams): boolean; export {};