schema.ts (914B)
1 import { z } from "zod"; 2 import { util_rxp } from "@radroots/utils"; 3 import type { 4 GeocoderReverseResult, 5 GeolocationAddress, 6 GeolocationPoint, 7 } from "./types.js"; 8 9 export const schema_geolocation_address: z.ZodSchema<GeolocationAddress> = z.object({ 10 primary: z.string().regex(util_rxp.addr_primary), 11 admin: z.string().regex(util_rxp.addr_admin), 12 country: z.string().regex(util_rxp.country_code_a2) 13 }); 14 15 export const schema_geocode_result: z.ZodSchema<GeocoderReverseResult> = z.object({ 16 id: z.number(), 17 name: z.string(), 18 admin1_id: z.union([z.string(), z.number()]), 19 admin1_name: z.string(), 20 country_id: z.string(), 21 country_name: z.string(), 22 latitude: z.number(), 23 longitude: z.number(), 24 }); 25 26 export const schema_geolocation_point: z.ZodSchema<GeolocationPoint> = z.object({ 27 lat: z.number().min(-90).max(90), 28 lng: z.number().min(-180).max(180), 29 });