From 11f929de00f565652dbf246db1fad9b00dd5bb76 Mon Sep 17 00:00:00 2001 From: ryanhamley Date: Mon, 18 Jun 2018 14:59:42 -0700 Subject: [PATCH] Throw ValidationError if required sprite property is not present --- src/style-spec/validate/validate_property.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/style-spec/validate/validate_property.js b/src/style-spec/validate/validate_property.js index 1c3d5c2e414..593c77873e8 100644 --- a/src/style-spec/validate/validate_property.js +++ b/src/style-spec/validate/validate_property.js @@ -13,6 +13,7 @@ export default function validateProperty(options, propertyType) { const value = options.value; const propertyKey = options.objectKey; const layerSpec = styleSpec[`${propertyType}_${options.layerType}`]; + const propsThatRequireSprite = ['background-pattern', 'fill-pattern', 'fill-extrusion-pattern', 'line-pattern', 'icon-image']; if (!layerSpec) return []; @@ -51,6 +52,12 @@ export default function validateProperty(options, propertyType) { } } + if (options.layerType === 'background' || options.layerType === 'fill' || options.layerType === 'fill-extrusion' || options.layerType === 'line' || options.layerType === 'symbol') { + if (propsThatRequireSprite.indexOf(propertyKey) > -1 && style && !style.sprite) { + errors.push(new ValidationError(key, value, `use of "${propertyKey}" requires a style "sprite" property`)); + } + } + return errors.concat(validate({ key: options.key, value,