Project Files
src / search / search-page-parameter.ts
/**
* Shared Zod schema describing the `page` parameter accepted by both Web Search and
* Image Search.
*/
import { z } from "zod"
/**
* Lower bound on the requested page number.
*/
const MIN_PAGE_NUMBER = 1
/**
* Upper bound on the requested page number.
*/
const MAX_PAGE_NUMBER = 100
/**
* Default page number when the caller omits the parameter.
*/
const DEFAULT_PAGE_NUMBER = 1
/**
* Reusable Zod schema applied to the `page` parameter of both search tools; bounds the value
* to a one-based page number within the engines' practical pagination range.
*/
export const searchPageParameter = z
.number()
.int()
.min(MIN_PAGE_NUMBER)
.max(MAX_PAGE_NUMBER)
.optional()
.default(DEFAULT_PAGE_NUMBER)
.describe("The current page number for pagination.")