From 425dba9740e23faf242e3372b20c2fd0b0d8b268 Mon Sep 17 00:00:00 2001 From: Lauren Budorick Date: Thu, 20 Jul 2017 09:12:09 -0700 Subject: [PATCH] Don't enforce ascending order for categorical function stops (#4996) --- src/style-spec/validate/validate_function.js | 2 +- .../style-spec/fixture/functions.input.json | 40 +++++++++++++++++++ .../style-spec/fixture/functions.output.json | 4 ++ 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/style-spec/validate/validate_function.js b/src/style-spec/validate/validate_function.js index d5be399e1f6..621f2bfb0b8 100644 --- a/src/style-spec/validate/validate_function.js +++ b/src/style-spec/validate/validate_function.js @@ -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; diff --git a/test/unit/style-spec/fixture/functions.input.json b/test/unit/style-spec/fixture/functions.input.json index e8e0d00e75c..0ea12eaacd1 100644 --- a/test/unit/style-spec/fixture/functions.input.json +++ b/test/unit/style-spec/fixture/functions.input.json @@ -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 + ] + ] + } + } } ] } diff --git a/test/unit/style-spec/fixture/functions.output.json b/test/unit/style-spec/fixture/functions.output.json index 6be8ad42595..ca6101efda3 100644 --- a/test/unit/style-spec/fixture/functions.output.json +++ b/test/unit/style-spec/fixture/functions.output.json @@ -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 } ] \ No newline at end of file