diff --git a/src/style-spec/validate/validate_function.js b/src/style-spec/validate/validate_function.js index b7a9bf3f616..a63ce3a2443 100644 --- a/src/style-spec/validate/validate_function.js +++ b/src/style-spec/validate/validate_function.js @@ -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; @@ -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]`, diff --git a/test/unit/style-spec/fixture/functions.input.json b/test/unit/style-spec/fixture/functions.input.json index 5fded8e46c8..808de749063 100644 --- a/test/unit/style-spec/fixture/functions.input.json +++ b/test/unit/style-spec/fixture/functions.input.json @@ -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", diff --git a/test/unit/style-spec/fixture/functions.output.json b/test/unit/style-spec/fixture/functions.output.json index 6526a72217e..26f78c5e6ef 100644 --- a/test/unit/style-spec/fixture/functions.output.json +++ b/test/unit/style-spec/fixture/functions.output.json @@ -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 @@ -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 } ] \ No newline at end of file