I am not a lawyer but I know that a contract has to be fair and obey other laws to be valid.
IANAL, this whole post may be and probably is wrong. Please correct me.
None of this is legal advice, just broad overview for the purposes of a purely academic discussion. There are a lot of details that are omitted, so do not rely on anything said here but consult your own attorney instead.