Skip to content

Commit

Permalink
Not all exponential function range values need be numbers
Browse files Browse the repository at this point in the history
The prior validate.array does the necessary type checking.

Fixes #301
  • Loading branch information
jfirebaugh committed Jun 19, 2015
1 parent 77fe929 commit c42164f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
13 changes: 0 additions & 13 deletions lib/validate/parsed.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,19 +337,6 @@ module.exports = function(style, reference) {

// Ensure all range values are of the correct type
validate.array(key + '.range', val.range, {type: "array", value: spec});

// Ensure all range values are of the same type and interpolate-able
if (functionType === 'exponential') {
var type = typeof_(val.range[0]);

if (type === 'array') {
var length = val.range[0].length;
validate.array(key + '.range', val.range, {type: "array", value: {type: "array", value: "number", length: length}});
} else {
validate.array(key + '.range', val.range, {type: "array", value: "number"});
}

}
};

validate['function-v7'] = function(key, val, spec) {
Expand Down
14 changes: 14 additions & 0 deletions test/fixture/functions.input.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,20 @@
"range": [[1,2], [2,4]]
}
}
},
{
"id": "13 valid exponential scale with color",
"type": "line",
"source": "source",
"source-layer": "layer",
"paint": {
"line-color": {
"property": "mapbox",
"domain": [1, 2],
"range": ["#000000", "#FFFFFF"],
"base": 1.5
}
}
}
]
}
4 changes: 0 additions & 4 deletions test/fixture/functions.output.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
"message": "layers[3].paint.fill-color.range[0]: color expected, boolean found",
"line": 61
},
{
"message": "layers[3].paint.fill-color.range[0]: number expected, boolean found",
"line": 61
},
{
"message": "layers[4].paint.line-width.domain[0]: number expected, boolean found",
"line": 74
Expand Down

0 comments on commit c42164f

Please sign in to comment.