mesqueeb / is-what

JS type check (TypeScript supported) functions like `isPlainObject() isArray()` etc. A simple & small integration.
https://mesqueeb.github.io/is-what/
MIT License
185 stars 20 forks source link

feat: Add `isMongoId` function to check for valid MongoId #89

Open omarangaritaj opened 5 months ago

omarangaritaj commented 5 months ago

This commit introduces a new function, isMongoId, that checks if a given string is a valid MongoDB ID. The function has been exported in the main index file and includes unit tests to ensure proper validation.

mesqueeb commented 5 months ago

@omarangaritaj thank you very much, but I'm a bit hesitant for this one. 😅 this is very specific to the mongo library. If I allow this, don't we also need detection of isFirestoreId? And then the list goes on of services....

What I'm trying to say, I'm not sure I want to integrate service specific functions into is-what, and keep is-what more about just vanilla JS/TS/NodeJS

omarangaritaj commented 5 months ago

@omarangaritaj thank you very much, but I'm a bit hesitant for this one. 😅 this is very specific to the mongo library. If I allow this, don't we also need detection of isFirestoreId? And then the list goes on of services....

What I'm trying to say, I'm not sure I want to integrate service specific functions into is-what, and keep is-what more about just vanilla JS/TS/NodeJS

Like a Swiss Army knife, isn't it better to have the tool available if you need it than to need it and not have it?

I just came to your repository because I got tired of doing typo checks: If (new Types.ObjectId('my_mongo_id') )