-
-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const _ = require('lodash'); | ||
const DEFAULT_SORT = 'distance'; | ||
|
||
const allowed_values = ['distance', 'popularity']; | ||
|
||
function _setup(){ | ||
|
||
return { | ||
sanitize: function _sanitize( raw, clean ){ | ||
|
||
// error & warning messages | ||
var messages = { errors: [], warnings: [] }; | ||
|
||
clean.sort = raw.sort; | ||
|
||
if( clean.sort && !allowed_values.includes(clean.sort) ){ | ||
messages.warnings.push('invalid \'sort\', using \'distance\''); | ||
clean.sort = DEFAULT_SORT; | ||
} | ||
|
||
return messages; | ||
}, | ||
|
||
expected: function _expected() { | ||
// add size as a valid parameter | ||
return [{ name: 'sort' }]; | ||
} | ||
}; | ||
} | ||
|
||
// export function | ||
module.exports = _setup; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters