There are an infinite number of things that could be included in an employment contract that would be unenforceable. Should conditions on other sources of income be enforceable?
There's a spectrum. Moonlighting for a direct competitor is obviously problematic. Moonlighting for a customer is also somewhat problematic, due to the appearance of a conflict of interest (is the customer getting special treatment out of hiring you? Are you ever in a position to take an action at either company which is influenced either by the secrets you know about the other or by their interests?)
Moonlighting for an unrelated business in the same field is less likely to be problematic, but in the case of, for example, Alphabet or Apple, exactly what are you doing that is definitely not a conflict of interest.
Moonlighting a second full-time job will in general cause you to be less effective at either than you would be absent the moonlighting, because human focus and energy are finite resources.
Moonlighting a part-time gig in a materially unrelated line of business is probably entirely conflict-of-interest free -- and nearly all employers would not attempt to stop you from doing so, though they may require you to tell them about it and let them verify that it actually is conflict-of-interest-free. (Of course, telling them might make them start paying close attention to whether or not you're getting "a full day's work" done in your day job, which, if you aren't, will probably cause you grief eventually)