Skip to content

Commit

Permalink
fixed pattern callback bug
Browse files Browse the repository at this point in the history
  • Loading branch information
mikestopcontinues committed Aug 30, 2014
1 parent adacf42 commit 7e19727
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
0.1.3 - August 30, 2014
-----------------------
* fixed pattern callback bug

0.1.2 - August 30, 2014
-----------------------
* allow default value to take callback function(file, data) returning default value
Expand Down
5 changes: 4 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ function plugin(matchers) {
}
}

if ('pattern' in validator && ((typeof validator.pattern === 'function' && !validator.pattern(data[key])) || !data[key].match(validator.pattern))) {
if ('pattern' in validator && (
(typeof validator.pattern === 'function' && !validator.pattern(data[key])) ||
(typeof validator.pattern !== 'function' && !data[key].match(validator.pattern))
)) {
err = new Error('File "' + file + '" value "' + key + '" does not match ' + validator.pattern + '.');
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "metalsmith-validate",
"description": "A Metalsmith plugin that allows you to easily validate file metadata, checking existence, type, and regex pattern.",
"repository": "git://github.com/mikestopcontinues/metalsmith-validate.git",
"version": "0.1.2",
"version": "0.1.3",
"author": "Mike Stop Continues <mikestopcontinues@gmail.com>",
"license": "MIT",
"main": "lib/index.js",
Expand Down

0 comments on commit 7e19727

Please sign in to comment.