def Coerce(type, message="<STR_LIT>"):
@wraps(Coerce)<EOL>def built(value):<EOL><INDENT>try:<EOL><INDENT>return type(value)<EOL><DEDENT>except (TypeError, ValueError) as e:<EOL><INDENT>raise Error(message.format(type.__name__))<EOL><DEDENT><DEDENT>return built<EOL>
Creates a validator that attempts to coerce the given value to the
specified ``type``. Will raise an error if the coercion fails.

A custom message can be specified with ``message``.