diff --git a/doc/main/contracts.html b/doc/main/contracts.html index 8cbecfe..2e1b53d 100644 --- a/doc/main/contracts.html +++ b/doc/main/contracts.html @@ -118,7 +118,8 @@
You can test that a value matches a regular expression by using a regular expression literal:
+@ (/username:\s*[a-zA-Z]*$/) -> Bool
+function checkUsername(str) {
+ // ...
+ return true;
+}
+
+checkUsername("username: bob"); // passes
+checkUsername("user: bob"); // fails
+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:
function MyNum(val) {
return typeof val === "number";