Skip to content

Commit dd4f981

Browse files
committed
adding ranges for pagination
1 parent 5eabe56 commit dd4f981

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages-v1/api-v1/trpc/utils/pagination.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ import {z} from 'zod'
22
import {Column, desc, schema} from '@openint/db'
33

44
export const zListParams = z.object({
5-
limit: z.number().optional(),
6-
offset: z.number().optional(),
5+
limit: z.number().int().positive().max(100).optional(),
6+
offset: z.number().int().nonnegative().optional(),
77
})
88

99
export function zListResponse<T extends z.ZodTypeAny>(itemSchema: T) {
1010
return z.object({
1111
items: z.array(itemSchema),
1212
total: z.number(),
13-
limit: z.number(),
14-
offset: z.number(),
13+
limit: z.number().int().positive().max(100),
14+
offset: z.number().int().nonnegative(),
1515
})
1616
}
1717
export function applyPaginationAndOrder<

0 commit comments

Comments
 (0)