Ale.js

Data type decision

Start

We can use a dataType property to make it easy for Ale.js to automatically determine if the data type is accurate:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
Ale("test", {
template: function(){
return this.data.key + this.staticData.val;
},
data: {
key: 1
},
staticData: {
val: 0
},
dataType: {
/* Add dataType here */
}
})

Inside the dataType you need to set a data or staticData to specify which type of data to make the decision in:

1
2
3
4
5
6
7
8
dataType: {
data: {

},
staticData: {

}
}

For example, we only accept parameters of numeric type: [If it is a constructor type, then ale will use the instanceOf keyword to determine]

1
2
3
4
5
6
7
8
dataType: {
data: {
key: Number
},
staticData: {
val: Number
}
}

Or: [If it is a string type, then ale will use the typeof keyword to determine]

1
2
3
4
5
6
7
8
dataType: {
data: {
key: "number"
},
staticData: {
val: "number"
}
}


Found some errors? Edit on Github!