0

I´m new to nodejs.

I have a route defined like this:

router.route('/sku/:id')
    .get((...args) => controllers.sku.findById(...args))

However, I´d like to know if there´s a way to ensure that this route only gets called if the id is a valid MongooseId. That check could be performed using:

require('mongoose').Types.ObjectId.isValid

I was also trying to accomplish it by using some regex, but no luck so far.

Thanks

0 Answers0