Extract logic to function
Actually include the detail in the exception message
Extract constant
Add support for restricting the valid placeholders

This doesn't affect what happens when the template is actually sent,
instead offering a way to preview the restrictions. It is up to the
consuming application to ensure that the two sets of placeholder
values are the same.