@cd2/file-validator
v0.3.0
Published
Check if a given file matches either a given extension of mimetype
Downloads
9
Readme
@cd2/file-validator
Check if a given file matches either a given extension of mimetype
isFileAllowed(file: File, allowed: string | string[]): boolean
file: The file to check allowed: One of more file type specifiers
Examples
isFileAllowed(file, '.png')
isFileAllowed(file, '.pdf,.csv')
isFileAllowed(file, 'application/pdf')
isFileAllowed(file, 'text/plain')
isFileAllowed(file, 'image/*') // any image
isFileAllowed(file, ["application/pdf", ".csv"]) // any pdf file or file with extension .csv