the below code works perfectly fine:
@MaxFileSize(10e6, { each: true }) // ** 10 MB limit
@HasExtension(['jpeg', 'png', 'jpg'], MetaSource.bufferMagicNumber, {
each: true,
})
@HasMimeType(['image/jpeg', 'image/png', 'image/jpg'], { each: true })
@IsFiles({ message: 'areaPhotos must only contain files' })
@IsNotEmpty()
areaPhotos: FileSystemStoredFile;
but when i change areaPhotos from areaPhotos: FileSystemStoredFile; to areaPhotos: FileSystemStoredFile[]; making sure typescript knows it is an array of files, it fails.
in this function
function isFile(value) {
console.log("???? ~ isFile ~ value:", value)
console.log("???? ~ isFile ~ value:", value && value instanceof StoredFile_1.StoredFile)
return value && value instanceof StoredFile_1.StoredFile;
}
in the library code i have seen that value looks like this
???? ~ isFile ~ value: [
originalName: 'Screenshot from 2024-06-11 09-44-16.png',
encoding: '7bit',
busBoyMimeType: 'image/png',
path: '/home/jamal/projects/rx-trade-backend/uploads/Screenshot from 2024-06-11 09-44-16-a5fd66.png',
size: 320685,
fileType: { ext: 'png', mime: 'image/png' }
]
which causes the validation to fail.