"By the book."
The Uniform Code of Military Justice (UCMJ)
Members of the military are subject to many rules, regulations and laws. Besides having to obey the laws of the United States and their host countries in times of peace under international treaties, they are also subject to a special set of laws made just for them, the Uniform Code of Military Justice or UCMJ.
The UCMJ is federal law, enacted by Congress which applies to all active duty members as well as activated National Guard and Reserve members and military academy students. Some civilians serving in support of the military during wartime are also subject to the UCMJ.
The UCMJ was enacted in 1951, prior to that each service had their own set of legal regulations which changed during peacetime and wartime. The UCMJ was developed to make the legal system uniform across all services.
Congress created the UCMJ and periodically makes changes to it through legislation, usually as part of the National Defense Authorization Act or NDAA.
https://www.usmchangout.com/military/military-legal/military-separation-codes.htm
https://jsc.defense.gov/Portals/99/Documents/UCMJ%20-%2020December2019.pdf?ver=2020-01-28-083235-930
https://uscode.house.gov/view.xhtml?path=%2Fprelim%40title10%2FsubtitleA%2Fpart2%2Fchapter47&edition=prelim
https://www.military.com/join-armed-forces/the-uniform-code-of-military-justice-ucmj.html