mirror of
https://github.com/atlanticbiomedical/biomedjs.git
synced 2025-07-02 00:47:26 -04:00
25 lines
422 B
JavaScript
25 lines
422 B
JavaScript
|
|
'use strict';
|
|
|
|
var moment = require('moment');
|
|
var expressValidator = require('express-validator');
|
|
|
|
module.exports = function() {
|
|
return expressValidator({
|
|
customValidators: {
|
|
isWeek
|
|
},
|
|
customSanitizers: {
|
|
toMoment
|
|
}
|
|
});
|
|
};
|
|
|
|
function isWeek(str) {
|
|
let week = moment(str, 'YYYY-MM-DD');
|
|
return week.isValid() && week.weekday() === 0;
|
|
}
|
|
|
|
function toMoment(str) {
|
|
return moment(str);
|
|
} |