136
rated 0 times
[
138]
[
2]
/ answers: 1 / hits: 17008
/ 6 Years ago, tue, july 10, 2018, 12:00:00
I want to validate DateTime like this code below
{
data: {
start: 2018-05-12 08:00:00
}
}
How to combine isISO8601() and match(regex) to validate date & time in start
body('*.start')
.exists()
.not()
.isEmpty()
.withMessage('start cannot be empty')
.isISO8601('yyyy-mm-dd')
.matches('^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$')
.withMessage('start must be in correct format yyyy:mm:dd hh:mm:ss'),
More From » node.js