import { ObjectId } from 'mongodb' ; export async function isObjectId ( val ) { try { ObjectId . createFromHexString ( val ) ; } catch ( e ) { throw new Error ( 'Not a valid ObjectId hex string' ) ; } return val ; }