Closed mondyfy closed 1 year ago
@mondyfy
Hi! Thanks for your feedback!
For mark field as optional use @IsOptional()
decorator then class-validator will know that the field is optional.
Here's an example
Please close your issue if it is solved
Sorry I missed that part, the issue was with the null value passed in the key:
curl --request POST \
--url http://localhost:3000/api/v1/candidate-story \
--header 'Content-Type: multipart/form-data' \
--form file=
As it has been resolved, closing as completed. Thank you @dmitriy-nz
Current Behavior: When using the![image](https://github.com/dmitriy-nz/nestjs-form-data/assets/30776170/679a9d73-b4d5-48a0-9f66-d3a8e4f67592)
nestjs-form-data
package, it seems that there is no built-in support for handling optional file validation. The library provides excellent support for handling file uploads, but it lacks a feature to easily specify that a file upload is optional and should not trigger validation errors if absent.Validations used:![image](https://github.com/dmitriy-nz/nestjs-form-data/assets/30776170/5dde78c3-1aae-4cde-a1dd-d9a510b75bf3)
Expected Behavior: I would expect the
nestjs-form-data
library to have a mechanism to define certain file fields as optional, meaning that if a file is not provided during the upload, it should not trigger validation errors.Steps to Reproduce:
nestjs-form-data
where a file upload is optional.Environment:
nestjs-form-data
version: 1.9.0Additional Context: I believe that adding support for optional file validation would enhance the usability and flexibility of the
nestjs-form-data
, especially in scenarios where certain files are not required for every upload.