mirror of
https://github.com/yusufipk/OpenFrame.git
synced 2026-09-11 17:46:06 +00:00
feat(projects): add validation for project visibility in PATCH request
This commit is contained in:
@@ -112,6 +112,11 @@ export async function PATCH(request: NextRequest, { params }: RouteParams) {
|
|||||||
const body = await request.json();
|
const body = await request.json();
|
||||||
const { name, description, visibility } = body;
|
const { name, description, visibility } = body;
|
||||||
|
|
||||||
|
const VALID_VISIBILITY = ['PRIVATE', 'INVITE', 'PUBLIC'] as const;
|
||||||
|
if (visibility !== undefined && !VALID_VISIBILITY.includes(visibility)) {
|
||||||
|
return apiErrors.badRequest('Invalid visibility value');
|
||||||
|
}
|
||||||
|
|
||||||
const updateData: Record<string, unknown> = {};
|
const updateData: Record<string, unknown> = {};
|
||||||
if (name !== undefined) updateData.name = name.trim();
|
if (name !== undefined) updateData.name = name.trim();
|
||||||
if (description !== undefined) updateData.description = description?.trim() || null;
|
if (description !== undefined) updateData.description = description?.trim() || null;
|
||||||
|
|||||||
Reference in New Issue
Block a user