Oops, he did it again. Photo: Mandel Ngan/AFP/Getty Images

In his recent book on the roots and significance of government animus in American law, Brooklyn Law School professor William Araiza tells the story of how hard it’s been for courts to come up with a framework to scrutinize official acts that appear discriminatory but may or may not be unconstitutional. The framework itself isn’t exactly intuitive, he writes, but animus is different: If a judge finds that a government actor did something to harm a particular group simply because of who they are, the case is over. That something serves no legitimate public purpose and must be struck down.

Donald Trump may have done just that when he announced, to the dismay of just about everyone who cares about sensible public policy, that no transgender servicemen and -women would be allowed “to serve in any capacity” in the armed forces. To offer a veneer of legitimacy to this policy-by-Twitter, the president noted that the decision was made in consultation with high-ranking military officials and experts, and that the end goal was winning. “Our military must be focused on decisive and overwhelming victory and cannot be burdened with the tremendous medical costs and disruption that transgender in the military would entail,” he tweeted.

The pushback and confusion were severe, but courts should be equally punishing: Any attempt by the Trump administration to implement such a wholesale ban on trans service wouldn’t survive a legal challenge. And believe me, there’d be many of those.

For one, there are already thousands of trans servicemembers serving openly, thanks to an Obama-era policy that was far more exhaustive and considered than Trump’s latest outrage. And they’re not all serving in combat-ready capacities. As Columbia law professor Jamal Greene observed in Take Care, a legal blog, they could well be serving the country honorably as mechanics, nurses, cooks, chaplains, accountants, or any of the hundreds of jobs available to those in the service. To discharge them all just because of their transgender status would be a textbook example of a bare desire to harm a specific group.

That’s precisely how one of the travel-ban cases now pending before the Supreme Court went down, where a court found that Trump’s executive order banning people from several Mideast countries wasn’t really motivated by a legitimate national-security concern, but instead was “rooted in religious animus” toward members of the Islamic faith. Because protecting the nation from terrorists was secondary to Trump’s campaign pledge to institute a Muslim ban, the judges there found that the pledge infected the ban and thus struck it down. Similarly, a broad trans ban, untethered from the realities of military service, can’t possibly be expected to be found constitutional by any court.

Trump being Trump, the president could have meant that he wants to ban the acceptance of transgender recruits into the military — a move the Pentagon was considering since the previous administration. That effort seems to be dead in the water, and there a court would probably defer to Trump, since the government has broad leeway to set parameters for who may or may not enlist based on medical needs, according to legal experts consulted by Reuters.

But if Trump’s legal troubles as a candidate and president have taught us anything, it’s that he should be taken at his word and seriously at all times. This is not a drill. If and when he and the Pentagon act on his announcement that trans service isn’t welcome and are sued over such drastic reversal, they’ll have to do some heavy lifting to explain why a trans electrician or those on the front lines who are proud of their service are so disruptive to everyone else that they may be legitimately expelled from the forces.

They won’t be able to. And anything they offer, no matter how official-sounding, will collide head-on with the doctrine of animus. To borrow language from one of the doctrine’s architects, Justice Anthony Kennedy, the trans ban may be just the kind of “classification of persons undertaken for its own sake, something the Equal Protection Clause does not permit.”