UNPKG

libmodulor

Version:

A TypeScript library to create platform-agnostic applications

35 lines (34 loc) 1.28 kB
import type { ConstraintsForHuman, TName } from '../base/TBase.js'; import { TObject } from '../base/TObject.js'; import type { JSONSchemaType } from '../targets/json-schema.js'; import type { HTMLInputType } from '../targets/web.js'; import type { Validation } from '../Validation.js'; import { type FileMimeType } from './TFileMimeType.js'; import { type FileName } from './TFileName.js'; import { type FilePath } from './TFilePath.js'; import type { UIntQuantity } from './TUIntQuantity.js'; export type File = { name: FileName; size: UIntQuantity; type: FileMimeType; uri: FilePath; }; export interface TFileConstraints { accept: FileMimeType[]; maxSizeInBytes?: UIntQuantity; minSizeInBytes?: UIntQuantity; } export declare class TFile extends TObject<File> { protected fileConstraints: TFileConstraints; static readonly UNITS: string[]; constructor(fileConstraints: TFileConstraints); tName(): TName; example(): File; getConstraintsForHuman(): ConstraintsForHuman | null; htmlInputType(): HTMLInputType; jsonSchemaType(): JSONSchemaType; validate(): Validation; getFileConstraints(): TFileConstraints; fmtBytes(bytes: number, decimals?: number): string; withOneExample(name: File['name']): this; }