Skip to content
Snippets Groups Projects
pageableSchema.ts 468 B
Newer Older
Piotr Gawron's avatar
Piotr Gawron committed
import { z } from 'zod';
import { ZodTypeAny } from 'zod/lib/types';

// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
export const pageableSchema = <T extends ZodTypeAny>(type: T) =>
Piotr Gawron's avatar
Piotr Gawron committed
  z.object({
    totalPages: z.number().nonnegative(),
    totalElements: z.number().nonnegative(),
    numberOfElements: z.number().nonnegative(),
    size: z.number().nonnegative(),
Piotr Gawron's avatar
Piotr Gawron committed
    number: z.number().nonnegative(),
    content: z.array(type),
  });