Open ucharles opened 4 months ago
ObjectId.isValid()
import { ObjectId } from "bson";
const tagId = params.tagId;
if (!tagId) { return NextResponse.json( { message: "tagId is required", }, { status: 400 }, ); }
if (ObjectId.isValid(tagId) === false) { return NextResponse.json( { message: "Invalid tagId", }, { status: 400 }, ); }
예제
ObjectId.isValid()
를 사용const tagId = params.tagId;
if (!tagId) { return NextResponse.json( { message: "tagId is required", }, { status: 400 }, ); }
if (ObjectId.isValid(tagId) === false) { return NextResponse.json( { message: "Invalid tagId", }, { status: 400 }, ); }