Previously at work, we had some issues in our CMS where some content editors would quickly create a post without a title, save the draft or publish, then add a title later. This caused a few issues in our headless service for select post types key to our business model. Without going into too much detail, I needed a way to restrict publishing & saving draft posts (of any type) without a title. A quick internet search brought me to some decent responses on Stack Overflow, and one good one on Kellen Mace‘s site.
Kellens article was from 2015, so I thought I would update it for current 2022 standard.