-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add zod to deal with type validation
- Loading branch information
1 parent
02b95b4
commit 1bdfd21
Showing
4 changed files
with
1,816 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
import mongoose from 'mongoose'; | ||
import { z } from 'zod'; | ||
|
||
// Helper function to validate ObjectId | ||
function isValidObjectId(id: string): boolean { | ||
return mongoose.Types.ObjectId.isValid(id); | ||
} | ||
|
||
export { isValidObjectId }; | ||
// Helper zod function to validate ObjectId | ||
const paramsSchema = z.string().refine((val) => { | ||
return mongoose.Types.ObjectId.isValid(val); | ||
}); | ||
|
||
export { isValidObjectId, paramsSchema }; |
Oops, something went wrong.