how to make req.query only accepts date format like yyyy-mm-dd

81
January 21, 2021, at 03:20 AM

I want to ask how can I make my req.query only accepts date format like this YYYY-MM-DD and not just random number because my code still accepting numbers like "123456" in query.

Answer 1

You can try this code below:

const isValidDate = !(new Date('2021/01/20').toString().toLowerCase().includes('invalid'));
if (isValidDate) {
  console.log('Valid Date');
} else {
  console.log('InValid Date');
}

READ ALSO
Login page is verifying all users as good Django

Login page is verifying all users as good Django

I'm trying to build a login page in DjangoBut whenever I try to authenticate the user it doesn't work

163
how to calculate employee attendace data

how to calculate employee attendace data

this is the employee_attendance table in mysql in which i have 3 column id, emp_id and office_punchoffice_punch is employee in time or out time with date

95
Start Application class A from different Application class B in same Android bundle

Start Application class A from different Application class B in same Android bundle

I have Application class A in base module and i want to launch other Application Class B in dynamic feature module

88
Node Schedule with mongoDB

Node Schedule with mongoDB

I want to use Node Schedule to build a module that will backup my serversI have the configuration of the backup periodicity in a MongoDB

88