Skip to content

Commit

Permalink
Simplified syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshuawuyts committed Jun 6, 2014
1 parent 10844fc commit a15fdd8
Showing 1 changed file with 9 additions and 24 deletions.
33 changes: 9 additions & 24 deletions index.js
Expand Up @@ -23,52 +23,37 @@ function customs (type, target) {
switch (type) {

case 'array':
if ('[object Array]' == Object.prototype.toString.call(target)){
return true;
}
if ('[object Array]' == Object.prototype.toString.call(target)) return true;
return false;

case 'string':
if ('string' == typeof(target)) {
return true;
}
if ('string' == typeof target) return true;
return false;

case 'number':
if ('number' == typeof(target)) {
return true
};
if ('number' == typeof target) return true;
return false;

case 'boolean':
if ('boolean' == typeof(target)) {
return true;
}
if ('boolean' == typeof target) return true;
return false;

case 'object':
if ('object' == typeof(target)) {
return true;
}
if ('object' == typeof target) return true;
return false;

case 'email':
var regex = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
if (regex.test(target)) {
return true;
}
if (regex.test(target)) return true;
return false;

case 'function':
console.log(typeof target)
if('function' == typeof target) return true;
return false;

default:
// check and evaluate regex
if (type instanceof RegExp && type.test(target)) {
return true;
}
if (type instanceof RegExp && type.test(target)) return true;
return false;
}
}
};
};

0 comments on commit a15fdd8

Please sign in to comment.