Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

check ObjectId is valid in mongoose

const mongoose = require('mongoose');

console.log(mongoose.Types.ObjectId.isValid('53cb6b9b4f4ddef1ad47f943'));
// true
console.log(mongoose.Types.ObjectId.isValid('whatever'));
// false
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #check #ObjectId #valid #mongoose
ADD COMMENT
Topic
Name
5+4 =