Skip to content

Commit

Permalink
Throw ValidationError if required sprite property is not present
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanhamley committed Nov 2, 2018
1 parent fc7703e commit 11f929d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/style-spec/validate/validate_property.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 [];

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 11f929d

Please sign in to comment.