work in progress... worked on channel attributes and game goal. fixes #45 and references #48

This commit is contained in:
logsol 2014-03-30 00:12:04 +01:00
parent 039213cf50
commit 55256ada95
23 changed files with 409 additions and 110 deletions

View file

@ -0,0 +1,61 @@
define([
],
function () {
function validate(object, description) {
if(description.optional && (object === null || object === "")) {
return true;
}
if(object === null) {
return false;
}
if(typeof object === 'undefined') {
return false;
}
if(typeof object === 'NaN') {
return false;
}
if(description.type == 'array' && !(object instanceof Array)) {
return false;
}
if(description.type != 'array' && typeof object != description.type) {
return false;
}
if(description.max && object > description.max) {
return false;
}
if(description.min && object < description.min) {
return false;
}
if(description.maxLength && object.length > description.maxLength) {
return false;
}
if(description.minLength && object.length < description.minLength) {
return false;
}
if(description.in && description.in.indexOf(object) === -1) {
return false;
}
if(description.regex && !description.regex.test(object)) {
return false;
}
return true;
}
return validate;
});