IAMNAL but there’s usually a clause to say that if some part of the agreement isn’t valid/can’t be enforced/etc then the rest of the agreement stands regardless. Who knows how well that stands up though (probably lawyers somewhere, but I doubt it is cited often).