Files
TREK/server/src/nest/maps/trek-community.schema.ts
T
Maurice 41edbcf67a maps: validate the community values and OSM elements the TREK Places API answers
Both answers were taken as typed. A value outside the published shape, such
as hours that are no text, reached the hours parser and failed the details
request. A place outside the shape is now left out of /v1/community, and an
element outside it sends the lookup to Overpass.
2026-10-31 03:25:56 +00:00

15 lines
749 B
TypeScript

import { z } from 'zod';
/** What the service publishes for a place found elsewhere (Photon, Overpass): the overlay of its own rows. */
export const trekCommunityValuesSchema = z.object({
contact: z
.object({ website: z.string().nullish(), phone: z.string().nullish(), email: z.string().nullish() })
.nullish(),
hours: z.object({ osm: z.string().nullish() }).nullish(),
description: z.object({ text: z.string().nullish() }).nullish(),
images: z.array(z.object({ url: z.string().optional(), cover: z.boolean().optional() })).nullish(),
community: z.object({ version: z.number().int().optional(), fields: z.array(z.string()).optional() }).nullish(),
});
export type TrekCommunityValues = z.infer<typeof trekCommunityValuesSchema>;