Permalink
Switch branches/tags
Find file
Fetching contributors…
Cannot retrieve contributors at this time
16 lines (16 sloc) 5.1 KB
<!DOCTYPE html>
<html><head><link href="css/default.css" rel="stylesheet" type="text/css"><script src="js/jquery.min.js" type="text/javascript"></script><script src="js/page_effects.js" type="text/javascript"></script><title>noir.validation documentation</title></head><body><div id="header"><h1><a href="index.html">Noir 1.3.0-beta1 API documentation</a></h1></div><div class="sidebar" id="namespaces"><h3>Namespaces</h3><ul><li><a href="noir.cookies.html"><span>noir.cookies</span></a></li><li><a href="noir.core.html"><span>noir.core</span></a></li><li><a href="noir.options.html"><span>noir.options</span></a></li><li><a href="noir.request.html"><span>noir.request</span></a></li><li><a href="noir.response.html"><span>noir.response</span></a></li><li><a href="noir.server.html"><span>noir.server</span></a></li><li><a href="noir.server.handler.html"><span>noir.server.handler</span></a></li><li><a href="noir.session.html"><span>noir.session</span></a></li><li><a href="noir.statuses.html"><span>noir.statuses</span></a></li><li><a href="noir.util.crypt.html"><span>noir.util.crypt</span></a></li><li><a href="noir.util.gae.html"><span>noir.util.gae</span></a></li><li><a href="noir.util.test.html"><span>noir.util.test</span></a></li><li class="current"><a href="noir.validation.html"><span>noir.validation</span></a></li></ul></div><div class="sidebar" id="vars"><h3>Public Vars</h3><ul><li><a href="noir.validation.html#var-errors%3F"><span>errors?</span></a></li><li><a href="noir.validation.html#var-get-errors"><span>get-errors</span></a></li><li><a href="noir.validation.html#var-has-value%3F"><span>has-value?</span></a></li><li><a href="noir.validation.html#var-has-values%3F"><span>has-values?</span></a></li><li><a href="noir.validation.html#var-is-email%3F"><span>is-email?</span></a></li><li><a href="noir.validation.html#var-max-length%3F"><span>max-length?</span></a></li><li><a href="noir.validation.html#var-min-length%3F"><span>min-length?</span></a></li><li><a href="noir.validation.html#var-not-nil%3F"><span>not-nil?</span></a></li><li><a href="noir.validation.html#var-on-error"><span>on-error</span></a></li><li><a href="noir.validation.html#var-rule"><span>rule</span></a></li><li><a href="noir.validation.html#var-set-error"><span>set-error</span></a></li></ul></div><div class="namespace-docs" id="content"><h2>noir.validation documentation</h2><pre class="doc">Functions for validating input and setting string errors on fields.
All fields are simply keys, meaning this can be a general error storage and
retrieval mechanism for the lifetime of a single request. Errors are not
persisted and are cleaned out at the end of the request.</pre><div class="public" id="var-errors%3F"><h3>errors?</h3><div class="usage"><code>(errors? &amp; field)</code></div><pre class="doc">For all fields given return true if any field contains errors. If none of the fields
contain errors, return false. If no fields are supplied return true if any errors exist.</pre></div><div class="public" id="var-get-errors"><h3>get-errors</h3><div class="usage"><code>(get-errors &amp; [field])</code></div><pre class="doc">Get the errors for the given field. This will return a vector of all error strings or nil.
</pre></div><div class="public" id="var-has-value%3F"><h3>has-value?</h3><div class="usage"><code>(has-value? v)</code></div><pre class="doc">Returns true if v is truthy and not an empty string.
</pre></div><div class="public" id="var-has-values%3F"><h3>has-values?</h3><div class="usage"><code>(has-values? coll)</code></div><pre class="doc">Returns true if all members of the collection has-value? This works on maps as well.
</pre></div><div class="public" id="var-is-email%3F"><h3>is-email?</h3><div class="usage"><code>(is-email? v)</code></div><pre class="doc">Returns true if v is an email address
</pre></div><div class="public" id="var-max-length%3F"><h3>max-length?</h3><div class="usage"><code>(max-length? v len)</code></div><pre class="doc">Returns true if v is less than or equal to the given len
</pre></div><div class="public" id="var-min-length%3F"><h3>min-length?</h3><div class="usage"><code>(min-length? v len)</code></div><pre class="doc">Returns true if v is greater than or equal to the given len
</pre></div><div class="public" id="var-not-nil%3F"><h3>not-nil?</h3><div class="usage"><code>(not-nil? v)</code></div><pre class="doc">Returns true if v is not nil
</pre></div><div class="public" id="var-on-error"><h3>on-error</h3><div class="usage"><code>(on-error field func)</code></div><pre class="doc">If the given field has an error, execute func and return its value
</pre></div><div class="public" id="var-rule"><h3>rule</h3><div class="usage"><code>(rule passed? [field error])</code></div><pre class="doc">If the passed? condition is not met, add the error text to the given field:
(rule (not-nil? username) [:username &quot;Usernames must have a value.&quot;])</pre></div><div class="public" id="var-set-error"><h3>set-error</h3><div class="usage"><code>(set-error field error)</code></div><pre class="doc">Explicitly set an error for the given field. This can be used to
create complex error cases, such as in a multi-step login process.</pre></div></div></body></html>