Skip to content

Commit

Permalink
Don't enforce ascending order for categorical function stops (#4996)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lauren Budorick authored Jul 20, 2017
1 parent 31444a7 commit 425dba9
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/style-spec/validate/validate_function.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ module.exports = function validateFunction(options) {
return [new ValidationError(options.key, options.value, 'integer expected, found %s', value)];
}

if (type === 'number' && previousStopDomainValue !== undefined && value < previousStopDomainValue) {
if (functionType !== 'categorical' && type === 'number' && previousStopDomainValue !== undefined && value < previousStopDomainValue) {
return [new ValidationError(options.key, options.value, 'stop domain values must appear in ascending order')];
} else {
previousStopDomainValue = value;
Expand Down
40 changes: 40 additions & 0 deletions test/unit/style-spec/fixture/functions.input.json
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,46 @@
"default": "invalid"
}
}
},
{
"id": "invalid interval property function non-ascending stop values",
"type": "fill",
"source": "source",
"source-layer": "layer",
"paint": {
"fill-opacity": {
"property": "mapbox",
"type": "interval",
"stops": [
[
1, 1
],
[
0, 0
]
]
}
}
},
{
"id": "valid categorical property function non-ascending stop values",
"type": "fill",
"source": "source",
"source-layer": "layer",
"paint": {
"fill-opacity": {
"property": "mapbox",
"type": "categorical",
"stops": [
[
1, 1
],
[
0, 0
]
]
}
}
}
]
}
4 changes: 4 additions & 0 deletions test/unit/style-spec/fixture/functions.output.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,9 @@
{
"message": "layers[43].paint.fill-color.default: color expected, \"invalid\" found",
"line": 839
},
{
"message": "layers[44].paint.fill-opacity.stops[1][0]: stop domain values must appear in ascending order",
"line": 857
}
]

0 comments on commit 425dba9

Please sign in to comment.