All written agreements entered into prior to July 1, 1987, between prospective spouses for the purpose of affecting any of the provisions of this chapter shall be valid and enforceable if otherwise valid as contracts.