Skip to content

Commit

Permalink
Add function support
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshuawuyts committed Jun 6, 2014
1 parent 84048dd commit 10844fc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ function customs (type, target) {
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
Expand Down
8 changes: 8 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ describe('#customs()', function () {
});
});

describe('case: function', function () {
it('should return true if a function is provided', function (done) {
customs('function', function(arg) {return arg}).should.equal(true);
customs('function', '123').should.equal(false);
done();
});
});

describe('case: default', function () {
it('should return true if a regex is validated', function (done) {
customs(/d(b+)d/g, 'cdbbdbsbz').should.equal(true);
Expand Down

0 comments on commit 10844fc

Please sign in to comment.