UNPKG

@tmlmobilidade/types

Version:
21 lines (20 loc) 1.06 kB
/* * */ import { PaginationSchema } from '@tmlmobilidade/go-types-shared'; import { z } from 'zod'; /* * */ export const GetAllDistrictsQuerySchema = z.object({ geojson: z.preprocess((val) => val === 'true' || val === '1', z.boolean()), }); /* * */ export const GetAllMunicipalitiesQuerySchema = GetAllDistrictsQuerySchema.extend({ district_ids: z .preprocess(val => typeof val === 'string' ? val.split(',').map(s => s.trim()).filter(Boolean) : val, z.array(z.string()).nullish()), }); /* * */ export const GetAllParishesQuerySchema = GetAllMunicipalitiesQuerySchema.extend({ municipality_ids: z .preprocess(val => typeof val === 'string' ? val.split(',').map(s => s.trim()).filter(Boolean) : val, z.array(z.string()).nullish()), }).extend(PaginationSchema.shape); /* * */ export const GetAllLocalitiesQuerySchema = GetAllParishesQuerySchema.extend({ parish_ids: z.preprocess(val => typeof val === 'string' ? val.split(',').map(s => s.trim()).filter(Boolean) : val, z.array(z.string()).nullish()), }).extend(PaginationSchema.shape);