fix: Server error when invalid 'sort' field is passed from an API client (#2000)

This commit is contained in:
Tom Moor
2021-03-31 18:54:02 -07:00
committed by GitHub
parent 2e64972574
commit 2ef0caba88
8 changed files with 34 additions and 4 deletions

View File

@ -18,6 +18,12 @@ export default function validation() {
}
};
ctx.assertSort = (value, model, message = "Invalid sort parameter") => {
if (!Object.keys(model.rawAttributes).includes(value)) {
throw new ValidationError(message);
}
};
ctx.assertNotEmpty = (value, message) => {
if (value === "") {
throw new ValidationError(message);