[ReactFilePondUpload] Does filepond wrapper allow validating a file upon upload (e.g. filename)?

Forge Component
(3)
Published on 27 May (5 days ago) by Stuart Harris
3 votes
Published on 27 May (5 days ago) by Stuart Harris

Hi again Stuart (and interested parties following ReactFilePondUpload component discussion ;)


In my project we will be doing some additional simple validations upon file upload. Besides the already supported AcceptedFileTypes (which accepts a MIME type to filter allowed images one additional validation is if the filename of the files being uploaded respects a particular format e.g. AAA-dddddd-dddd-aa-aaaaa.jpeg (A or a for characters a-z and d for digit) - this will probably require a callback for a regex expression or similar... but I can only find DropValidation configuration (boolean) field stating true/false... can customized validations be added to the file upload?


Thank you,

Pedro

Hi Pedro,

Another great question, thank you.

The forge component currently does not validate filenames, only file types.

I am not sure how this would work, but I will investigate and provide some options.

Stay tuned, back shortly.

Kind regards,

Stuart

Solution

Hi Pedro,

It turns out it is possible, but only when there is also a limitation on file types.

I have deployed a new version which hooks into the file type validation and checks for files that match a regex.  There are now three configuration options to support this, one to allow files that match, one to disallow files that match and another to specify if the matches are case sensitive.

See the demo page to try it out.

eg To match any file starting with "filename" use "Must Match Filename Regex" = ^filename.*$

I hope this works for you.

Kind regards,

Stuart

Solution

Thanks so much, Stuart. Will try it out!

...working like a charm. Thank you!