ian
ian2y ago

input validation type for paginationOpts?

What type should I use for input validation for paginationOpts?
1 Reply
ian
ianOP2y ago
Copying this from another thread. If you're using input validation on an endpoint that takes in paginationOpts for paginating data, you have two options for types:
paginationOpts: v.object({
numItems: v.number(),
id: v.number(),
cursor: v.union(v.null(), v.string()),
}),
paginationOpts: v.object({
numItems: v.number(),
id: v.number(),
cursor: v.union(v.null(), v.string()),
}),
Or paginationOpts: v.any() As long as you're just passing the pagination options into paginate, it's safe to not type check it, as paginate will throw an error if it's a bad format. Vote with a ➕ if you'd like us to provide v.paginationOpts()