Skip to content

Commit

Permalink
Merge pull request #33 from Eigen-Explorer/paginationQueryHotFix
Browse files Browse the repository at this point in the history
Hot fix - pagination query
  • Loading branch information
uditdc authored Apr 29, 2024
2 parents 32f4eff + fd69117 commit 54b4ef1
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions packages/api/src/schema/zod/schemas/paginationQuery.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
import z from '../';

export const PaginationQuerySchema = z.object({
skip: z.number().min(0).default(0),
take: z.number().min(1).default(12),
skip: z
.string()
.default('0')
.refine((val) => !isNaN(parseInt(val, 10)), {
message: 'Skip must be a valid integer',
})
.transform((val) => (val ? parseInt(val, 10) : 0))
.describe('The number of records to skip for pagination.')
.openapi({ example: 0 }),
take: z
.string()
.default('12')
.refine((val) => !isNaN(parseInt(val, 10)), {
message: 'Take must be a valid integer',
})
.transform((val) => (val ? parseInt(val, 10) : 12))
.describe('The number of records to return for pagination.')
.openapi({ example: 12 }),
});

0 comments on commit 54b4ef1

Please sign in to comment.