Validating file input
See original GitHub issueComing from Yup. I’m trying to validate a required file input with no success:
file: z.any().refine(val => val.length > 0, "File is required")
Any tips?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:6
- Comments:24 (3 by maintainers)
Top Results From Across the Web
File Type Validation while Uploading it using JavaScript
In this article, we will learn how to implement file type validation by checking file extension before uploading it using Javascript.
Read more >How to validate a file upload field using Javascript/jquery
Check it's value property: In jQuery (since your tag mentions it): $('#fileInput').val(). Or in vanilla JavaScript: document.
Read more >File Upload Validation Techniques - Triaxiom Security
We summarize some of the common file upload validation techniques that can and should be used to thwart many of the common file...
Read more >How to validate file input on a File Upload Widget in a ...
Answer · Check if the end user did not select a file to upload : Add an If with the Condition set to...
Read more ><input type="file"> - HTML: HyperText Markup Language | MDN
The accept attribute doesn't validate the types of the selected files; it provides hints for browsers to guide users towards selecting the ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Putting this here if anyone still has this problem. The solution that worked for me was this one:
No image provided
Too big
Wrong type
All good ✔
Then finally, in the data object we get
@colinhacks thanks for your answer. I am also looking for a solution. Can i also check if the File MIME-Type is for e.g. an
image/*
. How can i do that with zod?and when i try to use:
i get the error: