Skip to content

Commit 0119bf3

Browse files
committed
building documentation
1 parent a043a18 commit 0119bf3

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

doc/main/contracts.html

+13-2
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ <h1 class="title">Contracts.js Documentation</h1>
118118
<li><a href="#using"><span class="toc-section-number">3</span> Using</a></li>
119119
<li><a href="#contracts"><span class="toc-section-number">4</span> Contracts</a><ul>
120120
<li><a href="#basic-contracts"><span class="toc-section-number">4.1</span> Basic Contracts</a><ul>
121-
<li><a href="#custom-predicate-contracts"><span class="toc-section-number">4.1.1</span> Custom Predicate Contracts</a></li>
121+
<li><a href="#regular-expressions"><span class="toc-section-number">4.1.1</span> Regular Expressions</a></li>
122+
<li><a href="#custom-predicate-contracts"><span class="toc-section-number">4.1.2</span> Custom Predicate Contracts</a></li>
122123
</ul></li>
123124
<li><a href="#function-contracts"><span class="toc-section-number">4.2</span> Function Contracts</a><ul>
124125
<li><a href="#optional-arguments"><span class="toc-section-number">4.2.1</span> Optional Arguments</a></li>
@@ -248,7 +249,17 @@ <h2 id="basic-contracts"><span class="header-section-number">4.1</span> Basic Co
248249
</tr>
249250
</tbody>
250251
</table>
251-
<h3 id="custom-predicate-contracts"><span class="header-section-number">4.1.1</span> Custom Predicate Contracts</h3>
252+
<h3 id="regular-expressions"><span class="header-section-number">4.1.1</span> Regular Expressions</h3>
253+
<p>You can test that a value matches a regular expression by using a regular expression literal:</p>
254+
<pre class="js"><code>@ (/username:\s*[a-zA-Z]*$/) -&gt; Bool
255+
function checkUsername(str) {
256+
// ...
257+
return true;
258+
}
259+
260+
checkUsername(&quot;username: bob&quot;); // passes
261+
checkUsername(&quot;user: bob&quot;); // fails</code></pre>
262+
<h3 id="custom-predicate-contracts"><span class="header-section-number">4.1.2</span> Custom Predicate Contracts</h3>
252263
<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>
253264
<pre class="js"><code>function MyNum(val) {
254265
return typeof val === &quot;number&quot;;

0 commit comments

Comments
 (0)