Form field validation based on unique constraint

Hi

I'm working on a simple project in which a specific BDM has a unique constraint on a field, i.e the username. I want to enforce this constraint on the form too, meaning that I would like that a user receives an error message when tries to submit a new BDM instance with an already existing username. 

I thought to use the costraint on the process, but it seems that I cannot use the DAO functions to define a contract constraint , but only the input of the contract

Do you have any advice to solve this?