Skip to content

Commit

Permalink
Reject invalid request config properties (#254)
Browse files Browse the repository at this point in the history
Uses updated Fusspot's strictShape assertion.

Closes #239.
  • Loading branch information
davidtheclark committed Jul 12, 2018
1 parent 9b139ed commit 8cacd98
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Changelog

## HEAD

- **Change:** Throw validation error if request configuration object includes invalid properties. This is a breaking change because it could cause your code to throw a new validation error informing you of a mistake in your code. But there is no change to the library's functionality: you'll just need to clean up invalid properties.

## 0.2.0

- **Add:** Add Optimization API service.
- **Add:** Add Optimization API service.

## 0.1.3

Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"singleQuote": true
},
"dependencies": {
"@mapbox/fusspot": "^0.1.0",
"@mapbox/fusspot": "^0.2.1",
"@mapbox/parse-mapbox-token": "^0.2.0",
"@mapbox/polyline": "^1.0.0",
"eventemitter3": "^3.1.0",
Expand Down
3 changes: 1 addition & 2 deletions services/__tests__/tokens.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,12 @@ describe('updateToken', () => {
tokens.updateToken({
tokenId: 'foo',
scopes: ['styles:list'],
ownerId: 'chickentooth',
note: 'horseleg',
resources: ['one', 'two']
});
expect(tu.requestConfig(tokens)).toEqual({
path: '/tokens/v2/:ownerId/:tokenId',
params: { tokenId: 'foo', ownerId: 'chickentooth' },
params: { tokenId: 'foo' },
method: 'PATCH',
body: {
scopes: ['styles:list'],
Expand Down
2 changes: 1 addition & 1 deletion services/service-helpers/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function file(value) {
}

function assertShape(validatorObj, apiName) {
return v.assert(v.shape(validatorObj), apiName);
return v.assert(v.strictShape(validatorObj), apiName);
}

module.exports = xtend(v, {
Expand Down

0 comments on commit 8cacd98

Please sign in to comment.