Closed matgott closed 3 years ago
Hey! To validate an array of files, you can use the decorator @IsFile({ each: true })
or @IsFiles()
IsFiles decorator does not need to pass each option
Hey! To validate an array of files, you can use the decorator
@IsFile({ each: true })
or@IsFiles()
IsFiles decorator does not need to pass each option
Hi dmitriy! Without "each: true" in isFiles() I receive an error
With isFile({each: true}) works, maybe is a bug with isFiles().
Other thing, the data is parsed like this:
Is strange, the property "photos" isn't an array, but has nested object with the other file.
Yes you are right, I just released version 1.4.1 which fixed the problem Thank you :)
Yes you are right, I just released version 1.4.1 which fixed the problem Thank you :)
Thanks you for the quickly response. Now I don't receive that eror with isFiles but, with postman still asking me for an array of photos:
Try like this When sending an array as data, you must specify the index or like this
But with isFile({each: true}) works great! But, then probably there is a bug with isFiles()
Try like this When sending an array as data, you must specify the index or like this
Amazing, thanks!
Use @IsFile({each: true})
must be paired with@IsArray()
decorator
If you look closely, then when transferring an array of files without [] or [index] leads to the fact that there is only one file object in the field
For example DTO
export class FormDataTestDto {
@IsFile({ each: true })
@HasMimeType(['image/jpeg', 'image/png'], { each: true })
photos: FileSystemStoredFile[];
}
Request Debugger photos is not an array These are the features of the work of the mapper from form data to object
Maybe it needs to be documented
Hi, I'am triying to validate an array of files but I don't know how the request must be made.
This is my DTO:
And this is my request with postman: But still asking me for an array of photos.
Thanks in advance!