Skip to content

Commit

Permalink
v1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolab committed Feb 22, 2021
1 parent 4b3ce06 commit 489956e
Show file tree
Hide file tree
Showing 16 changed files with 557 additions and 157 deletions.
37 changes: 21 additions & 16 deletions docs/Check.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="generator" content="Crystal Docs 0.34.0">
<meta name="generator" content="Crystal Docs 0.35.1">
<meta name="crystal_docs.project_version" content="master-dev">
<meta name="crystal_docs.project_name" content="validator">



<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/doc.js"></script>

<svg class="hidden">
<symbol id="octicon-link" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path>
</symbol>
</svg>

<meta id="repository-name" content="validator">
<meta name="repository-name" content="validator">
<title>Check - validator master-dev</title>
<script type="text/javascript">
CrystalDocs.base_path = "";
</script>
</head>
<body>

<svg class="hidden">
<symbol id="octicon-link" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path>
</symbol>
</svg>
<div class="sidebar">
<div class="sidebar-header">
<div class="search-box">
Expand All @@ -44,7 +44,7 @@ <h1 class="project-name">
</div>
</div>

<div class="search-results" class="hidden">
<div class="search-results hidden">
<ul class="search-list"></ul>
</div>

Expand Down Expand Up @@ -86,6 +86,11 @@ <h1 class="project-name">

</li>

<li class=" " data-id="validator/Check/ValidationError" data-name="check::validationerror">
<a href="Check/ValidationError.html">ValidationError</a>

</li>

</ul>


Expand Down Expand Up @@ -256,15 +261,15 @@ <h2>
a series of checks (<code><a href="Check/Validation.html#check(key:Symbol%7CString,message:String,valid:Bool):Validation-instance-method">Validation#check</a></code>).
using an existing <em>errors</em> <code>Hash</code> (<code><a href="Check/Errors.html">Check::Errors</a></code>).</p>

<pre><code>v <span class="o">=</span> <span class="t">Check</span>.new_validation existing_errors</code></pre>
<pre><code class="language-crystal">v <span class="o">=</span> <span class="t">Check</span>.new_validation existing_errors</code></pre>

<p>Same as:</p>

<pre><code>v <span class="o">=</span> <span class="t">Check</span><span class="t">::</span><span class="t">Validation</span>.<span class="k">new</span> existing_errors</code></pre>
<pre><code class="language-crystal">v <span class="o">=</span> <span class="t">Check</span><span class="t">::</span><span class="t">Validation</span>.<span class="k">new</span> existing_errors</code></pre>

<p>Example to combine two hashes of validation errors:</p>

<pre><code>preview_validation <span class="o">=</span> <span class="t">Check</span>.new_validation
<pre><code class="language-crystal">preview_validation <span class="o">=</span> <span class="t">Check</span>.new_validation
v <span class="o">=</span> <span class="t">Check</span>.new_validation preview_validation.errors</code></pre>
</div>

Expand All @@ -287,11 +292,11 @@ <h2>
<p>Initializes a new <code><a href="Check/Validation.html">Validation</a></code> instance to combine
a series of checks (<code><a href="Check/Validation.html#check(key:Symbol%7CString,message:String,valid:Bool):Validation-instance-method">Validation#check</a></code>).</p>

<pre><code>v <span class="o">=</span> <span class="t">Check</span>.new_validation</code></pre>
<pre><code class="language-crystal">v <span class="o">=</span> <span class="t">Check</span>.new_validation</code></pre>

<p>Same as:</p>

<pre><code>v <span class="o">=</span> <span class="t">Check</span><span class="t">::</span><span class="t">Validation</span>.<span class="k">new</span></code></pre>
<pre><code class="language-crystal">v <span class="o">=</span> <span class="t">Check</span><span class="t">::</span><span class="t">Validation</span>.<span class="k">new</span></code></pre>
</div>

<br/>
Expand Down Expand Up @@ -328,7 +333,7 @@ <h2>
This mixin includes <code><a href="Check/Checkable.html">Checkable</a></code> and <code><a href="Check/CheckableStatic.html">CheckableStatic</a></code>.
It must be used in conjonction with <code><a href="Check.html#rules(**fields)-macro">Check.rules</a></code>.</p>

<pre><code><span class="k">require</span> <span class="s">&quot;validator/check&quot;</span>
<pre><code class="language-crystal"><span class="k">require</span> <span class="s">&quot;validator/check&quot;</span>

<span class="k">class</span> <span class="t">Article</span>
<span class="c"># Mixin</span>
Expand Down Expand Up @@ -379,7 +384,7 @@ <h2>

<p>Generates <code>check</code>, <code>check_{{field}}</code> and <code>clean_{{field}}</code> methods for <em>fields</em> (class variables).</p>

<pre><code><span class="k">require</span> <span class="s">&quot;validator/check&quot;</span>
<pre><code class="language-crystal"><span class="k">require</span> <span class="s">&quot;validator/check&quot;</span>

<span class="k">class</span> <span class="t">Article</span>
<span class="c"># Mixin</span>
Expand Down
27 changes: 16 additions & 11 deletions docs/Check/Checkable.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="generator" content="Crystal Docs 0.34.0">
<meta name="generator" content="Crystal Docs 0.35.1">
<meta name="crystal_docs.project_version" content="master-dev">
<meta name="crystal_docs.project_name" content="validator">



<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/doc.js"></script>

<svg class="hidden">
<symbol id="octicon-link" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path>
</symbol>
</svg>

<meta id="repository-name" content="validator">
<meta name="repository-name" content="validator">
<title>Check::Checkable - validator master-dev</title>
<script type="text/javascript">
CrystalDocs.base_path = "../";
</script>
</head>
<body>

<svg class="hidden">
<symbol id="octicon-link" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path>
</symbol>
</svg>
<div class="sidebar">
<div class="sidebar-header">
<div class="search-box">
Expand All @@ -44,7 +44,7 @@ <h1 class="project-name">
</div>
</div>

<div class="search-results" class="hidden">
<div class="search-results hidden">
<ul class="search-list"></ul>
</div>

Expand Down Expand Up @@ -86,6 +86,11 @@ <h1 class="project-name">

</li>

<li class=" " data-id="validator/Check/ValidationError" data-name="check::validationerror">
<a href="../Check/ValidationError.html">ValidationError</a>

</li>

</ul>


Expand Down Expand Up @@ -246,7 +251,7 @@ <h2>

<p>Lifecycle method triggered after each call of <code><a href="../Check/Checkable.html#check(required:Bool=true,format:Bool=true):Validation-instance-method">#check</a></code>.</p>

<pre><code><span class="c"># Triggered on instance: `user.check`</span>
<pre><code class="language-crystal"><span class="c"># Triggered on instance: `user.check`</span>
<span class="k">def</span> <span class="m">after_check</span>(v : <span class="t">Check</span><span class="t">::</span><span class="t">Validation</span>, required : <span class="t">Bool</span> <span class="o">=</span> <span class="n">true</span>, format : <span class="t">Bool</span> <span class="o">=</span> <span class="n">true</span>)
<span class="c"># Code...</span>
<span class="k">end</span></code></pre>
Expand All @@ -270,7 +275,7 @@ <h2>

<p>Lifecycle method triggered before each call of <code><a href="../Check/Checkable.html#check(required:Bool=true,format:Bool=true):Validation-instance-method">#check</a></code>.</p>

<pre><code><span class="c"># Triggered on instance: `user.check`</span>
<pre><code class="language-crystal"><span class="c"># Triggered on instance: `user.check`</span>
<span class="k">def</span> <span class="m">before_check</span>(v : <span class="t">Check</span><span class="t">::</span><span class="t">Validation</span>, required : <span class="t">Bool</span> <span class="o">=</span> <span class="n">true</span>, format : <span class="t">Bool</span> <span class="o">=</span> <span class="n">true</span>)
<span class="c"># Code...</span>
<span class="k">end</span></code></pre>
Expand Down
29 changes: 17 additions & 12 deletions docs/Check/CheckableStatic.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="generator" content="Crystal Docs 0.34.0">
<meta name="generator" content="Crystal Docs 0.35.1">
<meta name="crystal_docs.project_version" content="master-dev">
<meta name="crystal_docs.project_name" content="validator">



<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/doc.js"></script>

<svg class="hidden">
<symbol id="octicon-link" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path>
</symbol>
</svg>

<meta id="repository-name" content="validator">
<meta name="repository-name" content="validator">
<title>Check::CheckableStatic - validator master-dev</title>
<script type="text/javascript">
CrystalDocs.base_path = "../";
</script>
</head>
<body>

<svg class="hidden">
<symbol id="octicon-link" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path>
</symbol>
</svg>
<div class="sidebar">
<div class="sidebar-header">
<div class="search-box">
Expand All @@ -44,7 +44,7 @@ <h1 class="project-name">
</div>
</div>

<div class="search-results" class="hidden">
<div class="search-results hidden">
<ul class="search-list"></ul>
</div>

Expand Down Expand Up @@ -86,6 +86,11 @@ <h1 class="project-name">

</li>

<li class=" " data-id="validator/Check/ValidationError" data-name="check::validationerror">
<a href="../Check/ValidationError.html">ValidationError</a>

</li>

</ul>


Expand Down Expand Up @@ -278,7 +283,7 @@ <h2>
which is provided in the third argument.
You can update this cleaned hash but you have to return it.</p>

<pre><code><span class="c"># Triggered on a static call: `User.check(h)` (with a `Hash` or `JSON::Any`)</span>
<pre><code class="language-crystal"><span class="c"># Triggered on a static call: `User.check(h)` (with a `Hash` or `JSON::Any`)</span>
<span class="k">def</span> <span class="m">self</span>.after_check(v : <span class="t">Check</span><span class="t">::</span><span class="t">Validation</span>, h, cleaned_h, required : <span class="t">Bool</span> <span class="o">=</span> <span class="n">true</span>, format : <span class="t">Bool</span> <span class="o">=</span> <span class="n">true</span>) : <span class="t">Hash</span>
<span class="c"># Code...</span>
pp cleaned_h
Expand All @@ -304,7 +309,7 @@ <h2>

<p>Lifecycle method triggered before each call of <code><a href="../Check/CheckableStatic.html#check(v:Check::Validation,h:Hash,required:Bool=true,format:Bool=true)-instance-method">.check</a></code>.</p>

<pre><code><span class="c"># Triggered on a static call: `User.check(h)` (with a `Hash` or `JSON::Any`)</span>
<pre><code class="language-crystal"><span class="c"># Triggered on a static call: `User.check(h)` (with a `Hash` or `JSON::Any`)</span>
<span class="k">def</span> <span class="m">self</span>.before_check(v : <span class="t">Check</span><span class="t">::</span><span class="t">Validation</span>, h, required : <span class="t">Bool</span> <span class="o">=</span> <span class="n">true</span>, format : <span class="t">Bool</span> <span class="o">=</span> <span class="n">true</span>)
<span class="c"># Code...</span>
pp h
Expand Down Expand Up @@ -390,7 +395,7 @@ <h2>
that the <code>JSON.parse</code> has been processed successfully or not and the 2nd
argument is the <em>json</em> Hash.</p>

<pre><code>ok, user_h <span class="o">=</span> <span class="t">User</span>.h_from_json(json) <span class="c"># =&gt; true, {&quot;username&quot; =&gt; &quot;Bob&quot;, &quot;email&quot; =&gt; &quot;[email protected]&quot;}</span></code></pre>
<pre><code class="language-crystal">ok, user_h <span class="o">=</span> <span class="t">User</span>.h_from_json(json) <span class="c"># =&gt; true, {&quot;username&quot; =&gt; &quot;Bob&quot;, &quot;email&quot; =&gt; &quot;[email protected]&quot;}</span></code></pre>
</div>

<br/>
Expand Down
25 changes: 15 additions & 10 deletions docs/Check/Checker.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="generator" content="Crystal Docs 0.34.0">
<meta name="generator" content="Crystal Docs 0.35.1">
<meta name="crystal_docs.project_version" content="master-dev">
<meta name="crystal_docs.project_name" content="validator">



<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/doc.js"></script>

<svg class="hidden">
<symbol id="octicon-link" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path>
</symbol>
</svg>

<meta id="repository-name" content="validator">
<meta name="repository-name" content="validator">
<title>Check::Checker - validator master-dev</title>
<script type="text/javascript">
CrystalDocs.base_path = "../";
</script>
</head>
<body>

<svg class="hidden">
<symbol id="octicon-link" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path>
</symbol>
</svg>
<div class="sidebar">
<div class="sidebar-header">
<div class="search-box">
Expand All @@ -44,7 +44,7 @@ <h1 class="project-name">
</div>
</div>

<div class="search-results" class="hidden">
<div class="search-results hidden">
<ul class="search-list"></ul>
</div>

Expand Down Expand Up @@ -86,6 +86,11 @@ <h1 class="project-name">

</li>

<li class=" " data-id="validator/Check/ValidationError" data-name="check::validationerror">
<a href="../Check/ValidationError.html">ValidationError</a>

</li>

</ul>


Expand Down Expand Up @@ -139,7 +144,7 @@ <h2>

<p>Declare a method as a checker.</p>

<pre><code><span class="c"># Triggered by the instance.</span>
<pre><code class="language-crystal"><span class="c"># Triggered by the instance.</span>
@[<span class="t">Check</span><span class="t">::</span><span class="t">Checker</span>]
<span class="k">def</span> <span class="m">custom_checker</span>(v : <span class="t">Check</span><span class="t">::</span><span class="t">Validation</span>, required : <span class="t">Bool</span>, format : <span class="t">Bool</span>)
puts <span class="s">&quot;custom checker triggered on instance&quot;</span>
Expand Down
Loading

0 comments on commit 489956e

Please sign in to comment.