Current section
Files
Jump to
Current section
Files
gen/docs/validator/list/index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>validator/list - validator</title>
<link rel="stylesheet" href="../../index.css" type="text/css" />
</head>
<body>
<header class="page-header">
<h2>
validator<!-- - -->
</h2>
</header>
<div class="page">
<nav class="sidebar">
<a class="sidebar-toggle" href="#">
<svg
aria-hidden="true"
focusable="false"
data-prefix="fas"
data-icon="bars"
class="svg-inline--fa fa-bars fa-w-14"
role="img"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 448 512"
>
<path
fill="#fff"
d="M16 132h416c8.837 0 16-7.163 16-16V76c0-8.837-7.163-16-16-16H16C7.163 60 0 67.163 0 76v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16z"
></path>
</svg>
</a>
<h2>Pages</h2>
<ul>
<li><a href="../../index.html">README</a></li>
</ul>
<h2>Modules</h2>
<ul>
<li><a href="../../validator/">validator</a></li>
<li><a href="../../validator/common/">validator/common</a></li>
<li><a href="../../validator/int/">validator/int</a></li>
<li><a href="../../validator/list/">validator/list</a></li>
<li><a href="../../validator/option/">validator/option</a></li>
<li><a href="../../validator/string/">validator/string</a></li>
</ul>
<h2>Functions</h2>
<ul>
<li><a href="#every">every</a></li>
<li><a href="#is_not_empty">is_not_empty</a></li>
<li><a href="#max_length">max_length</a></li>
<li><a href="#min_length">min_length</a></li>
</ul>
</nav>
<div class="content">
<h1 class="module-name">validator/list</h1>
<section class="module-members">
<a href="#module-functions">
<h1 id="module-functions" class="module-member-kind">Functions</h1>
</a>
<div class="member">
<a href="#every">
<h2 id="every" class="member-name">
every
</h2>
</a>
<pre>pub fn every(
validator: fn(a) -> Result(b, tuple(c, List(c))),
) -> fn(List(a)) -> Result(List(a), tuple(c, List(c)))</pre>
<div class="rendered-markdown"><p>Validate a list of items.</p>
<p>Run the given validator for each item returning all the errors.</p>
<h2>Example</h2>
<pre><code>type Collection = { Collection(items: List(String) ) }
let list_validator = v_list.every(
v_string.min_length("Must be at least 3", 3)
)
let validator = fn(collection: Collection) {
v.build1(Collection)
|> v.validate(collection.items, list_validator)
}</code></pre>
</div>
</div>
<div class="member">
<a href="#is_not_empty">
<h2 id="is_not_empty" class="member-name">
is_not_empty
</h2>
</a>
<pre>pub fn is_not_empty(
error: a,
) -> fn(List(b)) -> Result(List(b), tuple(a, List(a)))</pre>
<div class="rendered-markdown"><p>Validate that a list is not empty</p>
</div>
</div>
<div class="member">
<a href="#max_length">
<h2 id="max_length" class="member-name">
max_length
</h2>
</a>
<pre>pub fn max_length(
error: a,
max: Int,
) -> fn(List(b)) -> Result(List(b), tuple(a, List(a)))</pre>
<div class="rendered-markdown"><p>Validate the max number of items in a list</p>
</div>
</div>
<div class="member">
<a href="#min_length">
<h2 id="min_length" class="member-name">
min_length
</h2>
</a>
<pre>pub fn min_length(
error: a,
min: Int,
) -> fn(List(b)) -> Result(List(b), tuple(a, List(a)))</pre>
<div class="rendered-markdown"><p>Validate the min number of items in a list</p>
</div>
</div>
</section>
</div>
</div>
<footer class="pride" onclick="document.querySelector('.pride').classList.toggle('show')">
<div class="blue">Lucy</div>
<div class="pink">says</div>
<div class="white">trans</div>
<div class="pink">rights</div>
<div class="blue">✨</div>
<a>✨</a>
</footer>
</body>
</html>