UNPKG

express-image-validator

Version:

Validator of various image parameters in Express.js applications

58 lines (57 loc) 1.42 kB
import type { ImageMimeTypes } from './mimeType'; /** * Options for validating uploaded image files. */ export type ValidationOptions = { /** * Maximum number of files allowed for this field. `null` means unlimited. * @default null */ limit?: number | null; /** * Minimum file size in megabytes. * @default 0 */ minSize?: number; /** * Maximum file size in megabytes. `null` means no upper limit. * @default null */ maxSize?: number | null; /** * Whether at least one file must be provided for this field. * @default false */ required?: boolean; /** * Enforced image aspect ratio (width / height). `null` disables the check. * @default null */ aspectRatio?: number | null; /** * Allowed image MIME types. `null` uses the built-in defaults: * 1) 'image/jpeg' * 2) 'image/png' * 3) 'image/gif' * 4) 'image/webp' * 5) 'image/bmp' * 6) 'image/tiff' * 7) 'image/svg+xml' * 8) 'image/avif'. * @default null */ allowedMimeTypes?: ImageMimeTypes | null; }; /** * Schema describing a single validated field. */ export type FieldSchema = { /** * Name of the multipart/form-data field to validate. */ name: string; /** * Validation options overriding the defaults for this field. */ options?: ValidationOptions; };