As others have pointed out, it's a stupid law, but nothing in the federal Constitution says that the State of California can't pass stupid laws.
How about the 9th Amendment? The people are supposed to have broad rights and the government narrow and few.