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

Added new validation type 'date' to validator module

This commit is contained in:
2022-03-08 00:00:52 +00:00
parent be08c58afa
commit 34c6478699
2 changed files with 61 additions and 0 deletions

View File

@@ -83,6 +83,18 @@ function validate(body, fields, validation = {}) {
fieldsMap.get(checkOpts[1])
);
break;
case 'date': {
const raw = fieldsMap.get(checkOpts);
const obj = new Date(raw);
valid = !isNaN(obj.getTime());
fieldsMap.set(checkOpts, {
raw: raw,
date: obj
});
break;
}
default:
throw new Error('Invalid validation type');
}