UNPKG

express-image-validator

Version:

Validator of various image parameters in Express.js applications

50 lines (49 loc) 1.61 kB
import type { Request } from 'express'; import type { ValidationError } from './validators'; type toArrayOptions = { /** * Whether only the first error of each field should be returned. * @default false */ onlyFirstError?: boolean; }; type MappedValidationError = Record<string, ValidationError[]>; /** * Copyright (c) 2025 [express-validator](https://github.com/express-validator). * * Licensed under the MIT License. * @see https://github.com/express-validator/express-validator/blob/61d3745e73ac628ac3a58dda02ba64d76d835630/src/validation-result.ts */ /** * The current state of the validation errors in a request. */ export declare class ValidationState { private readonly errors; constructor(errors: readonly ValidationError[]); /** * Gets the validation errors as an array. * * @param options.onlyFirstError Whether only the first error of each. */ array(options?: toArrayOptions): readonly ValidationError[] | ValidationError[][]; /** * Gets the validation errors as an object. * If a field has more than one error, only the first one is set in the resulting object. * * @returns An object from field name to error. */ mapped(): MappedValidationError; /** * @returns `true` if there are no errors, `false` otherwise. */ isEmpty(): boolean; /** * Throws an error if there are validation errors. */ throw(): void; } /** * Extracts the validation errors of an Express request */ export declare function imageValidationResult(req: Request): ValidationState; export {};