Skip to content
This repository has been archived by the owner on Apr 10, 2018. It is now read-only.

Commit

Permalink
Allow null as a filter operand
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Wojciechowski committed Feb 22, 2016
1 parent a3a26b4 commit 12c2e1f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/validate/validate_filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ module.exports = function validateFilter(options) {
}));
} else if (type === 'string' && value[i][0] === '@') {
errors.push(new ValidationError(key + '[' + i + ']', value[i], 'filter value cannot be a constant'));
} else if (type !== 'string' && type !== 'number' && type !== 'boolean') {
errors.push(new ValidationError(key + '[' + i + ']', value[i], 'string, number, or boolean expected, %s found', type));
} else if (type !== 'string' && type !== 'number' && type !== 'boolean' && value[i] !== null) {
errors.push(new ValidationError(key + '[' + i + ']', value[i], 'string, number, boolean, or null expected, %s found', type));
}
}
break;
Expand Down
11 changes: 11 additions & 0 deletions test/fixture/filters.input.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,17 @@
"any",
[]
]
},
{
"id": "value-null",
"type": "line",
"source": "source",
"source-layer": "source-layer",
"filter": [
"==",
"mapbox",
null
]
}
]
}
2 changes: 1 addition & 1 deletion test/fixture/filters.output.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"line": 59
},
{
"message": "layers[6].filter[2]: string, number, or boolean expected, array found",
"message": "layers[6].filter[2]: string, number, boolean, or null expected, array found",
"line": 71
},
{
Expand Down

0 comments on commit 12c2e1f

Please sign in to comment.