Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix validation error on categorical zoom-and-property functions #4220

Merged
merged 1 commit into from
Feb 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/style-spec/validate/validate_function.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = function validateFunction(options) {
const functionValueSpec = options.valueSpec;
const functionType = unbundle(options.value.type);
let stopKeyType;
const stopDomainValues = {};
let stopDomainValues = {};
let previousStopDomainValue;
let previousStopDomainZoom;

Expand Down Expand Up @@ -114,6 +114,7 @@ module.exports = function validateFunction(options) {
if (unbundle(value[0].zoom) !== previousStopDomainZoom) {
previousStopDomainZoom = unbundle(value[0].zoom);
previousStopDomainValue = undefined;
stopDomainValues = {};
}
errors = errors.concat(validateObject({
key: `${key}[0]`,
Expand Down
77 changes: 77 additions & 0 deletions test/unit/style-spec/fixture/functions.input.json
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,83 @@
}
}
},
{
"id": "invalid categorical zoom-and-property function - repeated stop",
"type": "fill",
"source": "source",
"source-layer": "layer",
"paint": {
"fill-opacity": {
"property": "mapbox",
"type": "categorical",
"stops": [
[
{
"zoom": 0,
"value": "0"
},
0
],
[
{
"zoom": 0,
"value": "1"
},
0
],
[
{
"zoom": 0,
"value": "0"
},
0
]
]
}
}
},
{
"id": "valid categorical zoom-and-property function",
"type": "fill",
"source": "source",
"source-layer": "layer",
"paint": {
"fill-opacity": {
"property": "mapbox",
"type": "categorical",
"stops": [
[
{
"zoom": 0,
"value": "0"
},
0
],
[
{
"zoom": 0,
"value": "1"
},
1
],
[
{
"zoom": 1,
"value": "0"
},
0
],
[
{
"zoom": 1,
"value": "1"
},
1
]
]
}
}
},
{
"id": "valid default",
"type": "fill",
Expand Down
18 changes: 11 additions & 7 deletions test/unit/style-spec/fixture/functions.output.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@
"message": "layers[19].paint.fill-color: \"property\" property is required",
"line": 354
},
{
"message": "layers[32].paint.fill-color.stops[0][0]: stop domain value must be a number, string, or boolean"
},
{
"message": "layers[22].paint.fill-color: missing required property \"property\"",
"line": 401
},
{
"message": "layers[32].paint.fill-color.stops[0][0]: stop domain value must be a number, string, or boolean"
},
{
"message": "layers[23].paint.fill-color.stops: identity function may not have a \"stops\" property",
"line": 415
Expand Down Expand Up @@ -147,11 +147,15 @@
"line": 718
},
{
"message": "layers[40].paint.fill-opacity.default: number expected, string found",
"line": 749
"message": "layers[39].paint.fill-opacity.stops[2][0].value: stop domain values must be unique",
"line": 754
},
{
"message": "layers[42].paint.fill-opacity.default: number expected, string found",
"line": 826
},
{
"message": "layers[41].paint.fill-color.default: color expected, \"invalid\" found",
"line": 762
"message": "layers[43].paint.fill-color.default: color expected, \"invalid\" found",
"line": 839
}
]