How to validate user input in a form

How can I make it so that when a user tries to create a channel it checks that there isn’t already a channel that has the same name that the user put in the form?

The picture shows how I attempted to solve this, and it didn’t work.

The first record in a collection is unique and cannot be duplicated, so if “name” is the first record in your channel collection it cannot be duplicated.