Entity exists Constraint

Is there anyway to use a constraint to check if an entity exists?

Can you share what your trying to do? I have feeling just giving answer to this might not be good enough.

Add an customer to an order, if the customer doesnt exist promt the user to create a custmer