Are anti-speculation agreements legal?

New Home Builders Occupance Period and use as princpal residence for one Year or more
& anti-speculation agreement legal in California or any state for that matter?
???