(b) Notwithstanding any provisions of this code to the contrary, beginning on July 1, 2015, it is an affirmative defense, or an affirmative partial defense, as the case may be, in any action to enforce a lien pursuant to this article that the owner is not indebted to the contractor or is indebted to the contractor for less than the amount of the lien sought to be perfected, when:
- (1) The property is an existing single-family dwelling;
- (2) The property is a residence constructed by the owner or under a contract entered into by the owner prior to its occupancy as the owner's primary residence; or
- (3) The property is a single-family, owner-occupied dwelling, including a residence constructed and sold for occupancy as a primary residence. This subdivision does not apply to a developer or builder of multiple residences except for the residence that is occupied as the primary residence of the developer or builder.