code: function checkType(type, value, errors) {
  	if (type) {
  		var actualType = typeof value;
  
  		if (typeof type == 'string') {
  			type = type.toLowerCase();
  			switch(type) {
  				case 'any':
  					return [];
  				case 'array':
  					if (!Array.isArray(value)) {
  						return [{
  							property: path,
  							message: 'expected an array, but ' + actualType + ' found instead'
  						}];
  					}
  					break;
  				case 'integer':
  				case 'int':
  					type = 'integer';
  					break;
  				case 'float':
  				case 'double':
  				case 'number':
  					type = 'number';
  					// fall through
  				default:
  					if (actualType != type) {
  						return [{
  							property: path,
  							message: 'expected ' + type + ', but ' + actualType + ' found instead'
  						}];
  					}
  					break;
  			}
  			return [];
  		}
  
  		if (Array.isArray(type)) {
  			var unionErrors = [];
  			for(var j = 0; j < type.length; j++) { // a union type
  				var errs = checkType(type[j], value, errors);
  				if (!errs.length) { return []; }
  				unionErrors = unionErrors.concat(errs);
  			}
  			return unionErrors;
  		} else if (typeof type == 'object') {
  			return checkProp(value, type, path);
  		}
  	}
  
  	return [];
  }
docs: validate a value against a type definition