Here is the my route for getting form data and isvalid function check the type of file and return true/false.
when i upload image with type jpg,jpeg,png isvalid function true and file uploded.and when i uplod pdf it give me error as expected but some dummy data is uploded in my upload folder .whenever validation failed it works expectedly but some dummy data stored in upload folder.
It is too late inside the form.parse callback to validate files, at this point they are already uploaded.
Try again with formidable version 3 and then use the filter option
options.filter {function} - default function that always returns true. Use it to filter files before they are uploaded. Must return a boolean.