How can a widget filter and validate files that user selects?
If you want to filter certain type of files you would want to implement data-input-accept-types option. It is also important to reject submissions that contain files other than the ones you explicitly permit. File validators will do exactly that.
Let's say you want your user to be able to submit only following file types: jpg, jpeg, gif, png, docx, xlsx, csv, rtf, pdf, mp4, mp3, ppt, pptx. Here is codepen that shows the implementation: