Well in the US we used to be forced to agree that no "non-whites" would reside at the property when we purchase it. Later SCOTUS would state such provisions are legal between private parties, but can't be enforced with the coercion of the government.
The same thing could happen with HOAs