stashing code
This commit is contained in:
34
packages/logic/domains/airport/data/entities.ts
Normal file
34
packages/logic/domains/airport/data/entities.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const numberModel = z
|
||||
.union([
|
||||
z.coerce
|
||||
.number()
|
||||
.refine((val) => !isNaN(val), { message: "Must be a valid number" }),
|
||||
z.undefined(),
|
||||
])
|
||||
.transform((value) => {
|
||||
return value !== undefined && isNaN(value) ? undefined : value;
|
||||
});
|
||||
|
||||
export const airportModel = z.object({
|
||||
id: z.coerce.number().int(),
|
||||
ident: z.string().nullable().optional(),
|
||||
type: z.string(),
|
||||
name: z.string(),
|
||||
latitudeDeg: numberModel.default(0.0),
|
||||
longitudeDeg: numberModel.default(0.0),
|
||||
elevationFt: numberModel.default(0.0),
|
||||
continent: z.string(),
|
||||
isoCountry: z.string(),
|
||||
country: z.string(),
|
||||
isoRegion: z.string(),
|
||||
municipality: z.string(),
|
||||
scheduledService: z.string(),
|
||||
gpsCode: z.coerce.string().default("----"),
|
||||
iataCode: z.coerce.string().min(1),
|
||||
localCode: z.coerce.string().default("----"),
|
||||
createdAt: z.coerce.date(),
|
||||
updatedAt: z.coerce.date(),
|
||||
});
|
||||
export type Airport = z.infer<typeof airportModel>;
|
||||
Reference in New Issue
Block a user