A contract like the one you describe is completely enforceable. People may make essentially any agreement or contract they like, so long as its terms are not themselves illegal (e.g. no contracts for murder, for tax fraud, for sexual favors, etc.). There is nothing illegal about agreeing to not hire someone's employees, or agreeing to pay a penalty or liquidated damages if one does. As long as there was no fraud (intentional lies) or coercion (force or threats) involved in creating the agreement, and the contracting parties were mentally competent adults, there is no reason to think that this contract would not be enforced by a court of law. In fact, contracts like the one you describe is not that uncommon a contract.