The Administrative Procedure Act (APA) of 1946 contains the rule that prevents the U.S. executive branch from acting in an arbitrary and capricious manner. Definitely not legit.
Please see Elgin v. Dept. of Treasury 567 U.S. 1 (2012) for details.
https://www.oyez.org/cases/2011/11-45
https://tile.loc.gov/storage-services/service/ll/usrep/usrep...
https://en.wikipedia.org/wiki/Department_of_Homeland_Securit...