Fix #16020: allow empty required custom fields

This is a port of the following 1.2.x commits:
- 890c36eb616cf5f1d115efa8b5de61b8b737937a
- 7ab6eb383a29a73ad65ade7de504d45477c87fb3

See related issues #12619, #11684 for details