No person shall be prosecuted for a violation of any provision of this code if the violation was required by a law of the federal government, by any rule, regulation, directive or order of any agency of the federal government, the violation of which is subject to penalty under an act of Congress, or by any valid order of military authority.