Discussion for a new feature - Validating files
Hello, I understand correctly in vine there is no file validation functionality ? Or did I miss something ?
@thetutlage , would you accept a PR for this feature??? I can implement it if it would be accepted
@thetutlage any response?
Hello @lubiah
Can you please share which Files will be validated by the File schema. It will be great if you can write a small proposal
Hi @thetutlage , here's a small proposal
Proposal: Introduce File Validation for VineJS
Objective Add validation functionality to handle File instances in VineJS, enabling developers to validate file attributes like type, size, and extension.
Proposed Validation Rules
-
file.maxSize: to validate the max size of a file instance -
file.minSize: to validate the min size of a file instance -
file.mimetypes([]), validates and checks if the instance mimetype is included in the array
Currently, there's no way of validating files in web forms and this would really help us to do that.
** References of the file validator in other validation libraries**
Where does the File class comes from? Remember VineJS works with Nodejs only and not in the browser
Hello, I don't know if I'm mistaken but the file class is also present in NodeJS. Here's a link to it in the NodeJS docs. In my project, I'm currently validating the files from formData in nodejs and it's working
I see. Yup, it will be a nice addition to have. We will need a new schema type for this. Lemme know if you are up for the PR?
I've already implemented it in my project. I'd be glad if you assign this issue to me. I'm ready to work on it
@thetutlage , can you kindly review the pull request