Skip to content

Commit

Permalink
building documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
disnet committed Aug 8, 2014
1 parent a043a18 commit 0119bf3
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions doc/main/contracts.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ <h1 class="title">Contracts.js Documentation</h1>
<li><a href="#using"><span class="toc-section-number">3</span> Using</a></li>
<li><a href="#contracts"><span class="toc-section-number">4</span> Contracts</a><ul>
<li><a href="#basic-contracts"><span class="toc-section-number">4.1</span> Basic Contracts</a><ul>
<li><a href="#custom-predicate-contracts"><span class="toc-section-number">4.1.1</span> Custom Predicate Contracts</a></li>
<li><a href="#regular-expressions"><span class="toc-section-number">4.1.1</span> Regular Expressions</a></li>
<li><a href="#custom-predicate-contracts"><span class="toc-section-number">4.1.2</span> Custom Predicate Contracts</a></li>
</ul></li>
<li><a href="#function-contracts"><span class="toc-section-number">4.2</span> Function Contracts</a><ul>
<li><a href="#optional-arguments"><span class="toc-section-number">4.2.1</span> Optional Arguments</a></li>
Expand Down Expand Up @@ -248,7 +249,17 @@ <h2 id="basic-contracts"><span class="header-section-number">4.1</span> Basic Co
</tr>
</tbody>
</table>
<h3 id="custom-predicate-contracts"><span class="header-section-number">4.1.1</span> Custom Predicate Contracts</h3>
<h3 id="regular-expressions"><span class="header-section-number">4.1.1</span> Regular Expressions</h3>
<p>You can test that a value matches a regular expression by using a regular expression literal:</p>
<pre class="js"><code>@ (/username:\s*[a-zA-Z]*$/) -&gt; Bool
function checkUsername(str) {
// ...
return true;
}

checkUsername(&quot;username: bob&quot;); // passes
checkUsername(&quot;user: bob&quot;); // fails</code></pre>
<h3 id="custom-predicate-contracts"><span class="header-section-number">4.1.2</span> Custom Predicate Contracts</h3>
<p>All of the basic contracts are built with predicates (functions that take a single value and return a boolean) and you can make your own:</p>
<pre class="js"><code>function MyNum(val) {
return typeof val === &quot;number&quot;;
Expand Down

0 comments on commit 0119bf3

Please sign in to comment.