-
Notifications
You must be signed in to change notification settings - Fork 0
/
amelinium.http.middleware.coercion.html
28 lines (28 loc) · 35 KB
/
amelinium.http.middleware.coercion.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<!DOCTYPE html PUBLIC ""
"">
<html><head><meta charset="UTF-8" /><title>amelinium.http.middleware.coercion documentation</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script><link rel="stylesheet" type="text/css" href="css/randomseed.css" /></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">Amelinium</span> <span class="project-version">1.0.1</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Topics</span></h3><ul><li class="depth-1 "><a href="10_introduction.html"><div class="inner"><span>Introduction</span></div></a></li><li class="depth-1 "><a href="20_hypermedia.html"><div class="inner"><span>Hypermedia-driven</span></div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><a href="amelinium.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>amelinium</span></div></a></li><li class="depth-2 branch"><a href="amelinium.admin.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>admin</span></div></a></li><li class="depth-2"><a href="amelinium.api.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>api</span></div></a></li><li class="depth-3"><a href="amelinium.api.controller.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>controller</span></div></a></li><li class="depth-4"><a href="amelinium.api.controller.user.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>user</span></div></a></li><li class="depth-3"><a href="amelinium.api.url.html"><div class="inner"><span class="tree" style="top: -52px;"><span class="top" style="height: 61px;"></span><span class="bottom"></span></span><span>url</span></div></a></li><li class="depth-2 branch"><a href="amelinium.app.html"><div class="inner"><span class="tree" style="top: -114px;"><span class="top" style="height: 123px;"></span><span class="bottom"></span></span><span>app</span></div></a></li><li class="depth-2"><a href="amelinium.auth.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>auth</span></div></a></li><li class="depth-3"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>algo</span></div></div></li><li class="depth-4 branch"><a href="amelinium.auth.algo.append.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>append</span></div></a></li><li class="depth-4 branch"><a href="amelinium.auth.algo.fail.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>fail</span></div></a></li><li class="depth-4 branch"><a href="amelinium.auth.algo.pbkdf2.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>pbkdf2</span></div></a></li><li class="depth-4"><a href="amelinium.auth.algo.scrypt.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>scrypt</span></div></a></li><li class="depth-3 branch"><a href="amelinium.auth.pwd.html"><div class="inner"><span class="tree" style="top: -145px;"><span class="top" style="height: 154px;"></span><span class="bottom"></span></span><span>pwd</span></div></a></li><li class="depth-3"><a href="amelinium.auth.specs.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>specs</span></div></a></li><li class="depth-2"><a href="amelinium.common.html"><div class="inner"><span class="tree" style="top: -238px;"><span class="top" style="height: 247px;"></span><span class="bottom"></span></span><span>common</span></div></a></li><li class="depth-3 branch"><a href="amelinium.common.controller.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>controller</span></div></a></li><li class="depth-3"><a href="amelinium.common.oplog.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>oplog</span></div></a></li><li class="depth-4"><a href="amelinium.common.oplog.auth.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>auth</span></div></a></li><li class="depth-3 branch"><a href="amelinium.common.populators.html"><div class="inner"><span class="tree" style="top: -52px;"><span class="top" style="height: 61px;"></span><span class="bottom"></span></span><span>populators</span></div></a></li><li class="depth-3"><a href="amelinium.common.swagger.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>swagger</span></div></a></li><li class="depth-2 branch"><a href="amelinium.core.html"><div class="inner"><span class="tree" style="top: -176px;"><span class="top" style="height: 185px;"></span><span class="bottom"></span></span><span>core</span></div></a></li><li class="depth-2"><a href="amelinium.db.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>db</span></div></a></li><li class="depth-3"><a href="amelinium.db.sql.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>sql</span></div></a></li><li class="depth-2 branch"><a href="amelinium.errors.html"><div class="inner"><span class="tree" style="top: -52px;"><span class="top" style="height: 61px;"></span><span class="bottom"></span></span><span>errors</span></div></a></li><li class="depth-2"><a href="amelinium.http.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>http</span></div></a></li><li class="depth-3"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>client</span></div></div></li><li class="depth-4"><a href="amelinium.http.client.twilio.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>twilio</span></div></a></li><li class="depth-3 branch"><a href="amelinium.http.handler.html"><div class="inner"><span class="tree" style="top: -52px;"><span class="top" style="height: 61px;"></span><span class="bottom"></span></span><span>handler</span></div></a></li><li class="depth-3"><a href="amelinium.http.middleware.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>middleware</span></div></a></li><li class="depth-4 branch current"><a href="amelinium.http.middleware.coercion.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>coercion</span></div></a></li><li class="depth-4 branch"><a href="amelinium.http.middleware.content.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>content</span></div></a></li><li class="depth-4 branch"><a href="amelinium.http.middleware.db.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>db</span></div></a></li><li class="depth-4 branch"><a href="amelinium.http.middleware.debug.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>debug</span></div></a></li><li class="depth-4 branch"><a href="amelinium.http.middleware.format.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>format</span></div></a></li><li class="depth-4 branch"><a href="amelinium.http.middleware.headers.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>headers</span></div></a></li><li class="depth-4 branch"><a href="amelinium.http.middleware.language.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>language</span></div></a></li><li class="depth-4 branch"><a href="amelinium.http.middleware.lazy-req.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>lazy-req</span></div></a></li><li class="depth-4 branch"><a href="amelinium.http.middleware.populators.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>populators</span></div></a></li><li class="depth-4 branch"><a href="amelinium.http.middleware.remote-ip.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>remote-ip</span></div></a></li><li class="depth-4 branch"><a href="amelinium.http.middleware.roles.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>roles</span></div></a></li><li class="depth-4 branch"><a href="amelinium.http.middleware.session.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>session</span></div></a></li><li class="depth-4"><a href="amelinium.http.middleware.validators.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>validators</span></div></a></li><li class="depth-3 branch"><a href="amelinium.http.router.html"><div class="inner"><span class="tree" style="top: -424px;"><span class="top" style="height: 433px;"></span><span class="bottom"></span></span><span>router</span></div></a></li><li class="depth-3"><a href="amelinium.http.server.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>server</span></div></a></li><li class="depth-4 branch"><a href="amelinium.http.server.jetty.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>jetty</span></div></a></li><li class="depth-4"><a href="amelinium.http.server.undertow.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>undertow</span></div></a></li><li class="depth-2"><a href="amelinium.i18n.html"><div class="inner"><span class="tree" style="top: -672px;"><span class="top" style="height: 681px;"></span><span class="bottom"></span></span><span>i18n</span></div></a></li><li class="depth-3"><a href="amelinium.i18n.pluralizers.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>pluralizers</span></div></a></li><li class="depth-2 branch"><a href="amelinium.identity.html"><div class="inner"><span class="tree" style="top: -52px;"><span class="top" style="height: 61px;"></span><span class="bottom"></span></span><span>identity</span></div></a></li><li class="depth-2 branch"><a href="amelinium.locale.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>locale</span></div></a></li><li class="depth-2 branch"><a href="amelinium.logging.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>logging</span></div></a></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>model</span></div></div></li><li class="depth-3 branch"><a href="amelinium.model.confirmation.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>confirmation</span></div></a></li><li class="depth-3"><a href="amelinium.model.user.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>user</span></div></a></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree" style="top: -83px;"><span class="top" style="height: 92px;"></span><span class="bottom"></span></span><span>proto</span></div></div></li><li class="depth-3 branch"><a href="amelinium.proto.auth.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>auth</span></div></a></li><li class="depth-3 branch"><a href="amelinium.proto.errors.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>errors</span></div></a></li><li class="depth-3 branch"><a href="amelinium.proto.identity.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>identity</span></div></a></li><li class="depth-3 branch"><a href="amelinium.proto.session.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>session</span></div></a></li><li class="depth-3"><a href="amelinium.proto.twilio.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>twilio</span></div></a></li><li class="depth-2 branch"><a href="amelinium.schemas.html"><div class="inner"><span class="tree" style="top: -176px;"><span class="top" style="height: 185px;"></span><span class="bottom"></span></span><span>schemas</span></div></a></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>server</span></div></div></li><li class="depth-3"><a href="amelinium.server.ssl.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>ssl</span></div></a></li><li class="depth-2 branch"><a href="amelinium.system.html"><div class="inner"><span class="tree" style="top: -52px;"><span class="top" style="height: 61px;"></span><span class="bottom"></span></span><span>system</span></div></a></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>types</span></div></div></li><li class="depth-3 branch"><a href="amelinium.types.auth.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>auth</span></div></a></li><li class="depth-3 branch"><a href="amelinium.types.db.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>db</span></div></a></li><li class="depth-3 branch"><a href="amelinium.types.errors.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>errors</span></div></a></li><li class="depth-3 branch"><a href="amelinium.types.identity.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>identity</span></div></a></li><li class="depth-3 branch"><a href="amelinium.types.session.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>session</span></div></a></li><li class="depth-3"><a href="amelinium.types.twilio.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>twilio</span></div></a></li><li class="depth-2 branch"><a href="amelinium.utils.html"><div class="inner"><span class="tree" style="top: -207px;"><span class="top" style="height: 216px;"></span><span class="bottom"></span></span><span>utils</span></div></a></li><li class="depth-2"><a href="amelinium.web.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>web</span></div></a></li><li class="depth-3"><a href="amelinium.web.controller.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>controller</span></div></a></li><li class="depth-4 branch"><a href="amelinium.web.controller.admin.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>admin</span></div></a></li><li class="depth-4"><a href="amelinium.web.controller.user.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>user</span></div></a></li><li class="depth-3 branch"><a href="amelinium.web.js.html"><div class="inner"><span class="tree" style="top: -83px;"><span class="top" style="height: 92px;"></span><span class="bottom"></span></span><span>js</span></div></a></li><li class="depth-3 branch"><a href="amelinium.web.taggers.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>taggers</span></div></a></li><li class="depth-3"><a href="amelinium.web.url.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>url</span></div></a></li></ul></div><div class="sidebar secondary"><h3><a href="#top"><span class="inner">Public Vars</span></a></h3><ul><li class="depth-1"><a href="amelinium.http.middleware.coercion.html#var-default-exception-handler"><div class="inner"><span>default-exception-handler</span></div></a></li><li class="depth-1"><a href="amelinium.http.middleware.coercion.html#var-explain-errors-simple"><div class="inner"><span>explain-errors-simple</span></div></a></li><li class="depth-1"><a href="amelinium.http.middleware.coercion.html#var-get-form-params"><div class="inner"><span>get-form-params</span></div></a></li><li class="depth-1"><a href="amelinium.http.middleware.coercion.html#var-handle-form-errors"><div class="inner"><span>handle-form-errors</span></div></a></li><li class="depth-1"><a href="amelinium.http.middleware.coercion.html#var-init-coercer"><div class="inner"><span>init-coercer</span></div></a></li><li class="depth-1"><a href="amelinium.http.middleware.coercion.html#var-init-exceptions-handler"><div class="inner"><span>init-exceptions-handler</span></div></a></li><li class="depth-1"><a href="amelinium.http.middleware.coercion.html#var-init-registry"><div class="inner"><span>init-registry</span></div></a></li><li class="depth-1"><a href="amelinium.http.middleware.coercion.html#var-inject-errors"><div class="inner"><span>inject-errors</span></div></a></li><li class="depth-1"><a href="amelinium.http.middleware.coercion.html#var-join-errors"><div class="inner"><span>join-errors</span></div></a></li><li class="depth-1"><a href="amelinium.http.middleware.coercion.html#var-join-errors-with-values"><div class="inner"><span>join-errors-with-values</span></div></a></li><li class="depth-1"><a href="amelinium.http.middleware.coercion.html#var-join-param-names"><div class="inner"><span>join-param-names</span></div></a></li><li class="depth-1"><a href="amelinium.http.middleware.coercion.html#var-list-errors-simple"><div class="inner"><span>list-errors-simple</span></div></a></li><li class="depth-1"><a href="amelinium.http.middleware.coercion.html#var-map-errors-simple"><div class="inner"><span>map-errors-simple</span></div></a></li><li class="depth-1"><a href="amelinium.http.middleware.coercion.html#var-param-type"><div class="inner"><span>param-type</span></div></a></li><li class="depth-1"><a href="amelinium.http.middleware.coercion.html#var-parse-errors"><div class="inner"><span>parse-errors</span></div></a></li><li class="depth-1"><a href="amelinium.http.middleware.coercion.html#var-parse-param-names"><div class="inner"><span>parse-param-names</span></div></a></li><li class="depth-1"><a href="amelinium.http.middleware.coercion.html#var-recode-errors-simple"><div class="inner"><span>recode-errors-simple</span></div></a></li><li class="depth-1"><a href="amelinium.http.middleware.coercion.html#var-remove-params"><div class="inner"><span>remove-params</span></div></a></li><li class="depth-1"><a href="amelinium.http.middleware.coercion.html#var-split-error"><div class="inner"><span>split-error</span></div></a></li><li class="depth-1"><a href="amelinium.http.middleware.coercion.html#var-translate-error"><div class="inner"><span>translate-error</span></div></a></li><li class="depth-1"><a href="amelinium.http.middleware.coercion.html#var-valid-param-name.3F"><div class="inner"><span>valid-param-name?</span></div></a></li></ul></div><div class="namespace-docs" id="content"><h1 class="anchor" id="top">amelinium.http.middleware.coercion</h1><h4 class="added">added in 1.0.0</h4><div class="doc"><div class="markdown"><p>amelinium service, HTTP parameters coercion.</p>
</div></div><div class="public anchor" id="var-default-exception-handler"><h3>default-exception-handler</h3><div class="usage"><code>(default-exception-handler req e responder raiser)</code></div><div class="doc"><div class="markdown"></div></div><div class="src-link"><a href="https://github.com/randomseed-io/amelinium/tree/1.0.1/src/amelinium/http/middleware/coercion.clj#L418">view source</a></div></div><div class="public anchor" id="var-explain-errors-simple"><h3>explain-errors-simple</h3><div class="usage"><code>(explain-errors-simple data translate-sub)</code></div><div class="doc"><div class="markdown"><p>Like <code>recode-errors-simple</code> but each error map contains the additional key <code>:parameter/message</code> containing a human-readable messages created with translation function <code>translate-sub</code>. Enriches the output map with <code>:parameter/name</code>, <code>:error/summary</code> and <code>:error/description</code> entries. To be used in API responses.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/amelinium/tree/1.0.1/src/amelinium/http/middleware/coercion.clj#L140">view source</a></div></div><div class="public anchor" id="var-get-form-params"><h3>get-form-params</h3><div class="usage"><code>(get-form-params req ids)</code></div><div class="doc"><div class="markdown"><p>Using the request map <code>req</code> gets the values of all parameters from <code>ids</code> (expressed as a sequence of strings). Returns a map where keys are parameter names and values are parameter values.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/amelinium/tree/1.0.1/src/amelinium/http/middleware/coercion.clj#L338">view source</a></div></div><div class="public anchor" id="var-handle-form-errors"><h3>handle-form-errors</h3><div class="usage"><code>(handle-form-errors req form-keep session-key)</code></div><div class="doc"><div class="markdown"><p>Tries to obtain form errors from a previously visited page, saved as a session variable <code>:form-errors</code> or as a query parameter <code>form-errors</code>.</p>
<p>The result is a map of at least 3 keys: <code>:errors</code> (parsed errors), <code>:dest</code> (destination URI, matching current URI if using a session variable), <code>:params</code> (map of other parameters and their values, only when session variable is a source).</p>
<p>The resulting map is then added to a request map under the <code>:form/errors</code> key and can be later used by form generating or other HTML rendering functions to display errors and previous form values.</p>
<p>It is intended to be used as a wrapper in coercion middleware so it can catch erroneous form fields which were reported back (via POST redirect using 307 code) and remove them from the request map’s parameter maps to avoid trouble when pre-filling in forms.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/amelinium/tree/1.0.1/src/amelinium/http/middleware/coercion.clj#L367">view source</a></div></div><div class="public anchor" id="var-init-coercer"><h3>init-coercer</h3><div class="usage"><code>(init-coercer k {:keys [init initializer config enabled?], :or {enabled? true}})</code></div><div class="doc"><div class="markdown"></div></div><div class="src-link"><a href="https://github.com/randomseed-io/amelinium/tree/1.0.1/src/amelinium/http/middleware/coercion.clj#L491">view source</a></div></div><div class="public anchor" id="var-init-exceptions-handler"><h3>init-exceptions-handler</h3><div class="usage"><code>(init-exceptions-handler k {enabled? :enabled?, exception-handler :handler, responder :responder, raiser :raiser, :or {enabled? true, exception-handler default-exception-handler, responder identity, raiser (fn* [p1__52224#] (throw p1__52224#))}})</code></div><div class="doc"><div class="markdown"></div></div><div class="src-link"><a href="https://github.com/randomseed-io/amelinium/tree/1.0.1/src/amelinium/http/middleware/coercion.clj#L449">view source</a></div></div><div class="public anchor" id="var-init-registry"><h3>init-registry</h3><div class="usage"><code>(init-registry config)</code></div><div class="doc"><div class="markdown"></div></div><div class="src-link"><a href="https://github.com/randomseed-io/amelinium/tree/1.0.1/src/amelinium/http/middleware/coercion.clj#L441">view source</a></div></div><div class="public anchor" id="var-inject-errors"><h3>inject-errors</h3><div class="usage"><code>(inject-errors req errors)</code></div><div class="doc"><div class="markdown"><p>Takes coercion errors, parses them, and puts into a newly created map under the key named <code>:errors</code> among with a current URI associated with the key <code>:dest</code>. The whole map is then injected into a request map <code>req</code> under the key <code>:form/errors</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/amelinium/tree/1.0.1/src/amelinium/http/middleware/coercion.clj#L320">view source</a></div></div><div class="public anchor" id="var-join-errors"><h3>join-errors</h3><div class="usage"><code>(join-errors errors)</code></div><div class="doc"><div class="markdown"><p>Used to produce a string containing parameter names and their types (as defined in schema) from a coercion errors simple map or coercion errors sequence (produced by <code>list-errors-simple</code> or <code>map-errors-simple</code> respectively).</p>
<p>For a non-empty string it simply returns it. Used to generate a query string containing form errors in a form of <code>parameter-id</code> or <code>parameter-id:parameter-type</code> separated by commas.</p>
<p>The whole string can then be encoded and used as a query parameter (i.e. <code>:form-errors</code>) when redirecting anonymous user to a page with a previous form which needs to be corrected.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/amelinium/tree/1.0.1/src/amelinium/http/middleware/coercion.clj#L186">view source</a></div></div><div class="public anchor" id="var-join-errors-with-values"><h3>join-errors-with-values</h3><div class="usage"><code>(join-errors-with-values errors)</code></div><div class="doc"><div class="markdown"><p>Used to produce a string containing parameter names and their types (as defined in schema) from a coercion errors simple map or coercion errors sequence (produced by <code>list-errors-simple</code> or <code>map-errors-simple</code> respectively). For anon-empty string it simply returns it. Used to generate a query string containing form errors in a form of <code>parameter-id</code> or <code>parameter-id:parameter-type:parameter-value</code> separated by commas. The whole string can then be encoded and used as a query parameter <code>:form-errors</code> when redirecting anonymous user to a page with a previous form which needs to be corrected. Be aware that it might be hard to parse the output string if a value contains a comma character.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/amelinium/tree/1.0.1/src/amelinium/http/middleware/coercion.clj#L211">view source</a></div></div><div class="public anchor" id="var-join-param-names"><h3>join-param-names</h3><div class="usage"><code>(join-param-names params)</code></div><div class="doc"><div class="markdown"><p>Used to produce a string containing parameter names from a map or a sequence.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/amelinium/tree/1.0.1/src/amelinium/http/middleware/coercion.clj#L170">view source</a></div></div><div class="public anchor" id="var-list-errors-simple"><h3>list-errors-simple</h3><div class="usage"><code>(list-errors-simple data)</code></div><div class="doc"><div class="markdown"><p>Returns a sequence of coercion errors consisting of 3-element sequences. First element of each being a parameter identifier (a string), second element being a parameter type described by schema (if detected, a string), and third being its current value. Takes an exception data map which should contain the <code>:coercion</code> key. Used, among other applications, to expose form errors to another page which should indicate them to a visitor.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/amelinium/tree/1.0.1/src/amelinium/http/middleware/coercion.clj#L149">view source</a></div></div><div class="public anchor" id="var-map-errors-simple"><h3>map-errors-simple</h3><div class="usage"><code>(map-errors-simple data)</code></div><div class="doc"><div class="markdown"><p>Like <code>list-errors-simple</code> but returns a map in which keys are parameter names and values are parameter types (as defined in a schema used to validate and coerce them). Used to pass form errors to another page which should expose them to a visitor.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/amelinium/tree/1.0.1/src/amelinium/http/middleware/coercion.clj#L162">view source</a></div></div><div class="public anchor" id="var-param-type"><h3>param-type</h3><div class="usage"><code>(param-type e)</code></div><div class="doc"><div class="markdown"><p>Takes a coercion error expressed as a map <code>e</code> and returns a string with parameter type if the type can easily be obtained (is a simple name expressed as a string or a string representation of keyword). For very complex schemas (which do not consist of a keyword or a vector with keyword at their first position) it returns <code>nil</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/amelinium/tree/1.0.1/src/amelinium/http/middleware/coercion.clj#L29">view source</a></div></div><div class="public anchor" id="var-parse-errors"><h3>parse-errors</h3><div class="usage"><code>(parse-errors errors)</code></div><div class="doc"><div class="markdown"><p>Transforms a string previously exposed with <code>join-errors</code>, a list created with <code>list-errors-simple</code> or a map resulted from calling <code>map-errors-simple</code>, into a map containing parameter names as keys and parameter types as values.</p>
<p>Used to parse input from a query string or saved session variable when visiting a page containing a previously visited form which needs to be corrected (after redirecting to it).</p>
<p>The <code>explain-form-error</code> template tag can make use of such map to decide whether an input field had invalid data.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/amelinium/tree/1.0.1/src/amelinium/http/middleware/coercion.clj#L291">view source</a></div></div><div class="public anchor" id="var-parse-param-names"><h3>parse-param-names</h3><div class="usage"><code>(parse-param-names s)</code></div><div class="doc"><div class="markdown"><p>Takes a parameter names separated by commas, removes duplicates and empty strings, and returns a sequence of strings.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/amelinium/tree/1.0.1/src/amelinium/http/middleware/coercion.clj#L329">view source</a></div></div><div class="public anchor" id="var-recode-errors-simple"><h3>recode-errors-simple</h3><div class="usage"><code>(recode-errors-simple data)</code></div><div class="doc"><div class="markdown"><p>Uses exception data to recode coercion errors in a form of a map. To be used mainly with API handlers. For web form error reporting <code>map-errors-simple</code>, <code>list-errors-simple</code> and <code>explain-errors-simple</code> are better suited.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/amelinium/tree/1.0.1/src/amelinium/http/middleware/coercion.clj#L113">view source</a></div></div><div class="public anchor" id="var-remove-params"><h3>remove-params</h3><div class="usage"><code>(remove-params req to-remove to-keep)</code></div><div class="doc"><div class="markdown"><p>Removes all parameters from known locations of the given request map <code>req</code> except of parameters listed in <code>to-keep</code> unless they also exist in <code>to-remove</code>.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/amelinium/tree/1.0.1/src/amelinium/http/middleware/coercion.clj#L348">view source</a></div></div><div class="public anchor" id="var-split-error"><h3>split-error</h3><div class="usage"><code>(split-error param-id param-type param-value)</code><code>(split-error param-id param-type)</code><code>(split-error param-id)</code></div><div class="doc"><div class="markdown"><p>Takes <code>param-id</code> and optional <code>param-type</code> and tries to clean-up their string representations to produce a 3-element vector. When only 1 argument is present or when the second argument is <code>nil</code> or empty, it will try to parse the first argument so if it contains a colon character it will be split into three parts: parameter ID, parameter type and value. Used as a helper by <code>parse-errors</code> and by argument parsers in template tags.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/amelinium/tree/1.0.1/src/amelinium/http/middleware/coercion.clj#L233">view source</a></div></div><div class="public anchor" id="var-translate-error"><h3>translate-error</h3><div class="usage"><code>(translate-error req param-error-properties req param-id param-type req lang param-id param-type translate-sub param-error-properties translate-sub param-id param-type)</code></div><div class="doc"><div class="markdown"><p>Takes a translation function with already applied language ID or a request map, parameter ID and parameter type and tries to find the best translations describing the erroneous field. Returns a map with the following keys <code>:parameter/name</code>, <code>:error/summary</code> and <code>:error/description</code>. To be used after receiving form errors data after a redirect.</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/amelinium/tree/1.0.1/src/amelinium/http/middleware/coercion.clj#L43">view source</a></div></div><div class="public anchor" id="var-valid-param-name.3F"><h3>valid-param-name?</h3><div class="usage"><code>(valid-param-name? s)</code></div><div class="doc"><div class="markdown"><p>Returns <code>true</code> if the given parameter name or parameter type name matches a pattern and can be sefely converted to an identifier (a keyword or a symbol).</p>
</div></div><div class="src-link"><a href="https://github.com/randomseed-io/amelinium/tree/1.0.1/src/amelinium/http/middleware/coercion.clj#L273">view source</a></div></div></div></body></html>