sharepoint online – How to restrict file extensions in document library

I’m using SharePointOnline’s Modern UI.

I would like to display an error message if a user uploads anything other than a PDF file in the document library.
Is there any way to achieve this other than an event receiver?

I would appreciate any ideas or pointers.