0.3.0 • Published 4 years ago

@cd2/file-validator v0.3.0

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

@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