Skip to content

Commit

Permalink
Add runtime checks
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanhamley committed Nov 21, 2019
1 parent 74c85f3 commit 23981b7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/style-spec/expression/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ export class StyleExpression {

try {
const val = this.expression.evaluate(this._evaluator);
if (val === null || val === undefined) {
// eslint-disable-next-line no-self-compare
if (val === null || val === undefined || (typeof val === 'number' && val !== val)) {
return this._defaultValue;
}
if (this._enumValues && !(val in this._enumValues)) {
Expand Down
25 changes: 25 additions & 0 deletions test/unit/style-spec/fixture/numbers.output-api-supported.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[
{
"line": 42,
"message": "layers[2].paint.circle-radius: -1 is less than the minimum value 0"
},
{
"message": "layers[3].paint.circle-radius: number expected, null found"
},
{
"line": 58,
"message": "layers[4].paint.circle-radius: missing required property \"stops\""
},
{
"line": 66,
"message": "layers[5].paint.circle-radius: number expected, array found"
},
{
"line": 74,
"message": "layers[6].paint.circle-radius: number expected, boolean found"
},
{
"line": 6,
"message": "source.data: Unsupported property \"data\""
}
]

0 comments on commit 23981b7

Please sign in to comment.