how do i validate if a datetime entered in the form has already been booked in another record?

I am creating a form to capture appointments for specialists and members... the schema of the appointments table looks something like this...

id (integer) specialist_id (integer) member_id (integer) description (string) start_at (datetime) duration (integer)

what i want to achieve is when trying to save a new appointment the data should be validated to check if an appointment is already booked for the specific specialist or member. in other words it should not allow me to book duplicate appointments for a specialist or member. any help would be highly appreciated.

thanks