
135 N.W.2d 222 (1965)
LEW BONN COMPANY, Plaintiff,
v.
Alen HERMAN and Tony L. Ferrara, individually, and dba Calhoun Terrace Company, Appellant,
Virgil L. Hillstrom, dba F. N. Hurd Company, Hurd Electric Co., and F. N. Hurd, Respondents.
No. 39457.
Supreme Court of Minnesota.
April 30, 1965.
*223 Leonard Street & Deinard and Jeremy C. Shea, Minneapolis, for appellant.
Louis J. Moriarty and Irving Frisch, Minneapolis, for respondents.
MURPHY, Justice.
This is an appeal from a judgment in favor of Virgil L. Hillstrom, doing business as F. N. Hurd Company, F. N. Hurd, and Hurd Electric Company, Inc., against Alen Herman and Tony L. Ferrara, individually and as partners under the trade name of Calhoun Terrace Company, hereinafter referred to as the Calhoun Company. The action grows out of extended lien claim litigation following the construction of an apartment building in Minneapolis. On appeal here the issue is reduced to the question of whether the failure of Hillstrom to file plans and specifications with the city building inspector as required by ordinance is sufficient ground to deny to him recovery for work performed as an electrical contractor.
From the record it appears that the Calhoun Company entered into an agreement with Hillstrom to perform the electrical work in the construction of the building. The basic plans for the building drawn by architects for the owners did not contain plans and specifications for electrical installations. The Calhoun Company did not employ an electrical engineer. Hillstrom performed this function as best he could. He secured a copy of the architect's plans, *224 superimposed his proposed electrical layout on them, and had sepia copies made of the sheet as the electrical plans and specifications. The contract was entered into on the basis of a condensed bill of materials. It was agreed that the work was to be installed in accordance with the city and state building codes. Section 4½(a) and (c) of the Electrical Ordinance of the city of Minneapolis, in effect when the contract was made, required that plans and specifications for new electrical installations in new buildings "for which plans and specifications are required for obtaining a building permit shall be submitted to the Department of Buildings for checking in every case where there is a combined electrical load of 30 KVA or over, or when requested by the Department of Buildings" so as to enable the Department of Buildings to check them for "safety, adequacy, and code compliance."[1]
After Hillstrom began work on April 14, 1959, he applied for and was issued a building permit. It does not appear, however, that he filed the plans and specifications of the electrical installations as required by the ordinance. It is contended that this failure renders the contract illegal so as to deny Hillstrom and his associates recovery of the sum of $10,435.18, the amount awarded by the trial court.
We discussed at considerable length the general subject relating to the validity of agreements which involve failure to comply with provisions of law in In re Estate of Peterson, 230 Minn. 478, 42 N.W.2d 59, 18 A.L.R.2d 910. It is unnecessary to again review that general subject since we conclude that the asserted breach relates entirely to a matter collateral to the agreement and that noncompliance under the circumstances of this case does not require that recovery be denied.
The trial court found that although the electrical plans and specifications were not filed, they were nevertheless available to the city electrical inspector and that the work was performed in full compliance with the electrical code and that the contract "was not an illegal contract." The record established that one of the city electrical inspectors was on the premises from time to time while the job was in progress for the purpose of inspecting the installations and that he had an opportunity to examine the plans and specifications. On examination, the inspector gave the following testimony:
"Q. Did Mr. Hillstrom invite you to inspect the prints of this building prior to his commencing work on it?
"A. Yes.
"Q. He did. And what did you tell him, Mr. Anderson?
"A. I told him that the Code would require a receptacle for every 12 feet of the perimeter of the room, and if that is what it had, it was all right.
"Q. And then you just refused to look at them?
"A. Well, I didn't take the time to look at them."
*225 The trial court was of the view that Hillstrom's failure to file plans and specifications did not under the circumstances deny to the other party benefits or protection which the ordinance was intended to give him and did not conflict with a public policy which would justify denial of recovery.
Although the general rule is that a contract entered into in violation of a statute which imposes a prohibition and a penalty for the doing of an act, such as the pursuit of a business, profession, or occupation without procuring a license or permit required by law for the protection of the public, is void, such rule is not to be applied without first examining the nature and circumstances of the contract in light of the applicable statute or ordinance. In construing such a statute or ordinance, courts will infer that the legislature did not intend that an instrument executed in violation of its terms should be void unless that be necessary to accomplish its purpose. 4 Dunnell, Dig. (3 ed.) § 1873. The general rule has been applied in this state with varying results. In Ingersoll v. Randall, 14 Minn. 400, Gil. 304, and Leuthold v. Stickney, 116 Minn. 299, 133 N.W. 856, contracts in violation of law were held to be unenforceable under circumstances where the violations offended important public policy with respect to health and safety of the public. However, in De Mers v. Daniels, 39 Minn. 158, 39 N.W. 98, and In re Estate of Peterson, supra, the holdings indicate that the breach of a provision of law as it bears upon the performance of a contract will not necessarily render the agreement unenforceable where the legislative intent to be found in the act would not indicate that its sanction should apply where the violation is slight, not seriously injurious to the public order, and where no wrong has resulted from want of compliance.
Appellants in their reply brief rely on 6 Williston, Contracts (Rev. ed.) § 1761, and Tocci v. Lembo, 325 Mass. 707, 92 N. E.2d 254. They neglect, however, to refer to the more recent Massachusetts decision of Buccella v. Schuster, 340 Mass. 323, 164 N.E.2d 141, in which both of the above authorities are discussed. The latter case, by which we are persuaded, involved an action to recover for labor performed and equipment rented pursuant to a contract for blasting a ledge on the defendant's premises. The plaintiff did the work without securing a permit or filing a bond as required by statute. There, as here, there was no evidence of the presence of evils which the statute or ordinance was intended to guard against, nor was there a possibility of damage from the happening of any event which the statute sought to prevent. There, as here, the failure to obtain the bond and permit was "only an incidental part of the performance of the contract." 340 Mass. 325, 164 N.E.2d 142. In holding that the failure to comply with the statute did not void the contract, the Massachusetts court said that the contractor's performance without the required bond and permit was not so repugnant to public policy "that the defendant should receive a gift of the plaintiff's services" and pointed out that the defendant "received all to which he was entitled under his contract." 340 Mass. 326, 164 N.E.2d 143.
The language of Mr. Justice Holmes, speaking for the Massachusetts court in Fox v. Rogers, 171 Mass. 546, 547, 50 N.E. 1041, 1042, is appropriate here. He said:
"We shall not trouble ourselves about the construction of the statute and ordinances, because it does not follow that the plaintiff cannot recover if he broke them. There is no policy of the law against the plaintiff's recovery unless his contract was illegal, and a contract is not necessarily illegal because it is carried out in an illegal way."
The contentions of appellants come down to the proposition that they are entitled to a windfall of more than $10,000 because of the failure of their creditor to comply strictly with the provisions of a *226 city ordinance. It could hardly be said that such a decision would be consonant with principles of justice where there is nothing in the record to indicate that when the contract was entered into there was any intention to violate the law, or to indicate bad motives or a design to deny the protection of law to one of a class for whose benefit the statute or ordinance was enacted. We do not think that the legislature intended that a slight violation relating to failure to comply with a collateral duty in the filing of plans and specifications should result in the forfeiture of a just debt. 4 Dunnell, Dig. (3 ed.) § 1873; 17 Am.Jur. (2d) Contracts, § 166. See, also, Annotation, 55 A.L.R.2d 481. We fully agree with the trial court that the Calhoun Company has received the benefit of Hillstrom's contributions to the construction of its property, that the work was performed in "compliance with the code in all material respects," and that it should be required to pay the judgment.
Affirmed.
NOTES
[1]  Minneapolis Code of Ordinances, §§ 141.080 and 141.100, now in effect, contain almost identical language.

Minn.St. 326.32, subd. 1, provides: "All electrical wiring, apparatus, and equipment for electric light, heat, and power shall comply with the rules and regulations of the railroad and warehouse commission, the commissioner of insurance, or the industrial commission, under the authority of the state statutes and in conformity with approved methods of construction for safety to life and property. The regulations as laid down in the national electrical code as approved by the American standards association, and in the national electrical safety code as issued by the United States bureau of standards, shall be prima facie evidence of such approved method; provided, that nothing herein contained shall prohibit any municipality from making and enforcing more stringent requirements than those set forth herein, and that such requirements shall be complied with by all licensed electricians working within the jurisdiction of such municipalities."
