mirror of
https://github.com/atlanticbiomedical/biomedjs.git
synced 2025-07-02 00:47:26 -04:00
Changes
This commit is contained in:
25
config/validators.js
Normal file
25
config/validators.js
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
'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);
|
||||
}
|
Reference in New Issue
Block a user