1
0
mirror of https://github.com/matt-fidd/stratos.git synced 2026-01-01 20:59:30 +00:00

Added values validator type

This commit is contained in:
2022-04-21 17:32:47 +00:00
parent fcde079023
commit 55dcc4bf46

View File

@@ -95,6 +95,22 @@ function validate(body, fields, validation = {}) {
});
break;
}
case 'values': {
const valueChecks = Object.entries(checkOpts);
for (const [ key, allowed ] of valueChecks) {
const valueValid = allowed.includes(
fieldsMap.get(key));
if (!valueValid) {
valid = false;
break;
}
valid = true;
}
break;
}
default:
throw new Error('Invalid validation type');
}