Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
23 lines
710 B
Plaintext
23 lines
710 B
Plaintext
import ObjectIdImport from 'bson-objectid';
|
|
const ObjectId = 'default' in ObjectIdImport ? ObjectIdImport.default : ObjectIdImport;
|
|
export const isValidID = (value, type)=>{
|
|
if (type === 'text' && value) {
|
|
if ([
|
|
'object',
|
|
'string'
|
|
].includes(typeof value)) {
|
|
const isObjectID = ObjectId.isValid(value);
|
|
return typeof value === 'string' || isObjectID;
|
|
}
|
|
return false;
|
|
}
|
|
if (type === 'number' && typeof value === 'number' && !Number.isNaN(value)) {
|
|
return true;
|
|
}
|
|
if (type === 'ObjectID') {
|
|
return ObjectId.isValid(String(value));
|
|
}
|
|
return false;
|
|
};
|
|
|
|
//# sourceMappingURL=isValidID.js.map |