Does prisma have a way to validate mongoID ? somet...
# mongodb
o
Does prisma have a way to validate mongoID ? something like
mongoose.Types.ObjectId.isValid('5c0a7922c9d89830f4911426')
j
Hi! I think this should work
Copy code
const ObjectID = require('bson').ObjectID;
// or
// import { ObjectID } from 'bson';

ObjectId.isValid("myid")
You will need the bson package
Copy code
npm install --save bson
o
Ok
I was hoping I would not need to bring in something external
j
This is only if you want to validate on your side, but it’s not needed to validate if you have
Copy code
id  String  @id @default(dbgenerated()) @map("_id") @db.ObjectId
the database will fail at runtime if you try to pass an invalid value