In any action on a contract, the defendant may file a pleading, alleging any matter arising out of the transaction which would entitle him to relief in equity or at law, including (i) failure in the consideration of such contract, (ii) fraud in such contract's procurement, (iii) breach of any other provision of such contract, (iv) breach of any duty imposed upon the plaintiff by law in the making or performance of such contract, or (v) any other matter arising out of the transaction that would entitle the defendant to recover damages from the plaintiff, or the person under whom the plaintiff claims, in whole or in part, against the obligation of the contract; or, if the contract be by deed, alleging any such matter arising under the contract, existing before its execution, or any such mistake therein, or in the execution thereof, or any such other matter arising out of the transaction as would entitle him to such relief in equity or at law; and in either case alleging the amount to which he is entitled by reason of the matters contained in the pleading. If the amount claimed by the defendant exceeds the amount of the plaintiff's claim, the court or jury may, in a proper case, give judgment in favor of the defendant for such excess.
Va. Code § 8.01-422