If a marriage or domestic partnership is determined to be void, an agreement that would otherwise have been a premarital agreement is enforceable only to the extent necessary to avoid an inequitable result, unless the agreement expressly provides that it shall be enforceable in the event that the marriage or domestic partnership is later determined to be void.