fix: protect delete customer form
This commit is contained in:
12
utils/validateContext.ts
Normal file
12
utils/validateContext.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { ContextSchema } from '@utils/types';
|
||||
|
||||
export function validateContext(context: any) {
|
||||
const validatedContext = ContextSchema.safeParse(context);
|
||||
if (!validatedContext.success) {
|
||||
throw new Error('Invalid context');
|
||||
}
|
||||
|
||||
const { id } = validatedContext.data.params;
|
||||
|
||||
return id;
|
||||
}
|
||||
Reference in New Issue
Block a user