StaticFileDef: {
    contentType?: string;
    fileSize?: IFileSize;
    max?: number;
    min?: number;
    name?: string | RegExp;
    optional?: boolean;
}

Static definition for validating an uploaded file's metadata.

Use this when the validation rules for a file field are known ahead of time and do not depend on the actual uploaded file. You can constrain the MIME type, file size, filename pattern, and whether the file is required or optional.

IMPORT_PATH: "@daiso-tech/core/http-router/contracts"

Type declaration

  • OptionalcontentType?: string

    Expected MIME type of the uploaded file (e.g. "image/png"). When set, validation fails if the uploaded file's content type does not match.

  • OptionalfileSize?: IFileSize

    Maximum allowed file size. Validation fails if the uploaded file exceeds this limit.

  • Optionalmax?: number

    Maximum number of files allowed for this field. Validation fails if more files are uploaded.

    1
    
  • Optionalmin?: number

    Minimum number of files required for this field. Validation fails if fewer files are uploaded.

    1 (0 if optional is true)

  • Optionalname?: string | RegExp

    Expected filename or a pattern the filename must match. When a string, the value is compared against the uploaded file's originalName (case-insensitive). When a RegExp, the filename must satisfy the pattern.

  • Optionaloptional?: boolean

    When true, the file is optional and validation passes even if no file is uploaded.

    false