mirror of
https://github.com/yusufipk/OpenFrame.git
synced 2026-09-11 17:46:06 +00:00
feat(progress): add validation for duration to ensure it is a non-negative finite number
This commit is contained in:
@@ -85,10 +85,14 @@ export async function POST(request: NextRequest, { params }: RouteParams) {
|
||||
const body = await request.json();
|
||||
const { progress, duration, versionId } = body;
|
||||
|
||||
if (typeof progress !== 'number' || progress < 0) {
|
||||
if (typeof progress !== 'number' || !isFinite(progress) || progress < 0) {
|
||||
return apiErrors.badRequest('Invalid progress value');
|
||||
}
|
||||
|
||||
if (duration !== undefined && (typeof duration !== 'number' || !isFinite(duration) || duration < 0)) {
|
||||
return apiErrors.badRequest('Invalid duration value');
|
||||
}
|
||||
|
||||
if (versionId !== undefined && typeof versionId !== 'string') {
|
||||
return apiErrors.badRequest('Invalid versionId');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user