Skip to content

Commit

Permalink
invalidate foregin memebers
Browse files Browse the repository at this point in the history
  • Loading branch information
jingsam committed May 31, 2019
1 parent e2eff01 commit 58fa110
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/style-spec/validate/validate_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ export default function validateSource(options) {
style: options.style,
styleSpec
});
if ('url' in value) {
for (const prop in value) {
if (['type', 'url', 'tiles', 'minzoom', 'maxzoom', 'attribution', 'mapbox_logo', 'bounds', 'scheme', 'tileSize', 'encoding'].indexOf(prop) < 0) {
errors.push(new ValidationError(`${key}.${prop}`, value[prop], `a source with a "url" property may not include a "${prop}" property`));
}
}
}
return errors;

case 'geojson':
Expand Down
4 changes: 4 additions & 0 deletions test/unit/style-spec/fixture/sources.output.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
"message": "sources.invalid-type.type: expected one of [vector, raster, raster-dem, geojson, video, image], \"invalid\" found",
"line": 7
},
{
"message": "sources.no-unknown-properties-with-url.foo: a source with a \"url\" property may not include a \"foo\" property",
"line": 17
},
{
"message": "sources.video-missing-coordinates: missing required property \"coordinates\"",
"line": 26
Expand Down

0 comments on commit 58fa110

Please sign in to comment.