2022-06-15 22:18:40 +00:00
|
|
|
import { withValidation } from "next-validations";
|
|
|
|
import { z } from "zod";
|
|
|
|
|
|
|
|
import { baseApiParams } from "./baseApiParams";
|
|
|
|
|
|
|
|
// Extracted out as utility function so can be reused
|
|
|
|
// at different endpoints that require this validation.
|
|
|
|
export const schemaQueryUserId = baseApiParams
|
|
|
|
.extend({
|
|
|
|
userId: z
|
|
|
|
.string()
|
|
|
|
.regex(/^\d+$/)
|
|
|
|
.transform((id) => parseInt(id)),
|
|
|
|
})
|
|
|
|
.strict();
|
2022-06-23 22:09:23 +00:00
|
|
|
export const withValidQueryUserId = withValidation({
|
|
|
|
schema: schemaQueryUserId,
|
|
|
|
type: "Zod",
|
|
|
|
mode: "query",
|
|
|
|
});
|