The following documentation comment has been logged on the website:
Page: https://www.postgresql.org/docs/9.6/static/sql-createdomain.html
Description:
The documentation of CREATE DOMAIN currently describes how optional
constraints can be useful for the fields of a table. There is no mention of
functions in this page.
I have recently found two use cases for domains with functions:
1. validation of the format of user inputs (mobile phone number, email
address, etc.) before any further processing in the function.
2. provide CURRENT_USER to a SECURITY DEFINER function (more details here:
http://stackoverflow.com/a/42011279/207968)