How to make UploadCare accept text only

I cannot find any resources or any clean documentation on accepting only “.txt” files. It would be great if you could guide and explain me the code

this thread might help:
https://uploadcare.com/community/t/how-to-limit-the-filetypes

and this page on validation: