code: function checkType(type,value){
               if(type){
                   if(typeof type == 'string' && type != 'any' &&
                           (type == 'null' ? value !== null : typeof value != type) &&
                           !(value instanceof Array && type == 'array') &&
                           !(value instanceof Date && type == 'date') &&
                           !(type == 'integer' && value%1===0)){
                       return [{property:path,message:(typeof value) + " value found, but a " + type + " is required"}];
                   }
                   if(type instanceof Array){
                       var unionErrors=[];
                       for(var j = 0; j < type.length; j++){ // a union type
                           if(!(unionErrors=checkType(type[j],value)).length){
                               break;
                           }
                       }
                       if(unionErrors.length){
                           return unionErrors;
                       }
                   }else if(typeof type == 'object'){
                       var priorErrors = errors;
                       errors = [];
                       checkProp(value,type,path);
                       var theseErrors = errors;
                       errors = priorErrors;
                       return theseErrors;
                   }
               }
               return [];
           }
docs: validate a value against a type definition