@@ -172,8 +172,8 @@ export async function getDistinctGenres(
172172export async function getMovieById ( req : Request , res : Response ) : Promise < void > {
173173 const { id } = req . params ;
174174
175- // Validate ObjectId format
176- if ( ! ObjectId . isValid ( id ) ) {
175+ // Validate id is a string and ObjectId format
176+ if ( typeof id !== "string" || ! ObjectId . isValid ( id ) ) {
177177 res
178178 . status ( 400 )
179179 . json (
@@ -305,8 +305,8 @@ export async function updateMovie(req: Request, res: Response): Promise<void> {
305305 const { id } = req . params ;
306306 const updateData : UpdateMovieRequest = req . body ;
307307
308- // Validate ObjectId format
309- if ( ! ObjectId . isValid ( id ) ) {
308+ // Validate id is a string and ObjectId format
309+ if ( typeof id !== "string" || ! ObjectId . isValid ( id ) ) {
310310 res
311311 . status ( 400 )
312312 . json (
@@ -426,8 +426,8 @@ export async function updateMoviesBatch(
426426export async function deleteMovie ( req : Request , res : Response ) : Promise < void > {
427427 const { id } = req . params ;
428428
429- // Validate ObjectId format
430- if ( ! ObjectId . isValid ( id ) ) {
429+ // Validate id is a string and ObjectId format
430+ if ( typeof id !== "string" || ! ObjectId . isValid ( id ) ) {
431431 res
432432 . status ( 400 )
433433 . json (
@@ -521,8 +521,8 @@ export async function findAndDeleteMovie(
521521) : Promise < void > {
522522 const { id } = req . params ;
523523
524- // Validate ObjectId format
525- if ( ! ObjectId . isValid ( id ) ) {
524+ // Validate id is a string and ObjectId format
525+ if ( typeof id !== "string" || ! ObjectId . isValid ( id ) ) {
526526 res
527527 . status ( 400 )
528528 . json (
0 commit comments