It is a valid defense if the law, or executive order, is unlawful. Yes, people have to suck up the consequences in the mean time, and be prepared a decision may go against them, but they are certainly free to act as they choose despite the fears of others.