Skip to content
Riccardo Cocetta edited this page Sep 22, 2015 · 18 revisions

Welcome to the r.cocetta/ kano-draw wiki!

How to validate steps:

validate is either a single element or an array of either string or object

If an element is a string it'll be considered a regex, if it's an object it'll be validated depending on the type. For the moment we only have type: fn which will contain a function which can receive a string representing the line that it's validating.

**NOTE ** The prefix @@ tells the validator that it has to escape the string to be a RegExp. You might want to use @@ when validating against something like @@mosquito = (x,y) ->

If the array contains more than one element, the validator will check more than 1 line.

"steps": [
    {
     "validate":     "^for *"
    },
    {
     "validate": [
         { 
           "type": "function",
           "fn"  : "function (str) {return str.length===3;}"
         }
     ]
    },
    {
     "validate": [
         "color white",
         { 
           "type": "function", 
           "fn"  : "function (str) {return str.length===3;}"
         }
     ]
    },

]
Clone this wiki locally