- Introduced Zod schemas for validation in the following entities: - Provincie - Ratelimiter - Rinnovi - Servizio - ServizioAnnunci - ServizioInteressi - TestiEStringhe - Users - UserEtichette - UserInvites - UsersAnagrafica - UsersStorage - VideosRefs - StatusConfermaEnum - TipologiaPosizioneEnum - Updated API routes in `catasto.ts` to include CRUD operations for Comuni, Nazioni, and Provincie with appropriate input validation. - Enhanced controller methods in `catasto.controller.ts` to handle create, edit, and delete operations for Comuni and Nazioni. - Added new utility Zod types for ComuniId, NazioniId, and ProvincieId. Co-authored-by: Copilot <copilot@github.com>
40 lines
No EOL
1.1 KiB
TypeScript
40 lines
No EOL
1.1 KiB
TypeScript
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
|
|
import { z } from 'zod';
|
|
|
|
/** Identifier type for public.provincie */
|
|
export type ProvincieId = number & { __brand: 'public.provincie' };
|
|
|
|
/** Represents the table public.provincie */
|
|
export default interface ProvincieTable {
|
|
id: ColumnType<ProvincieId, ProvincieId | undefined, ProvincieId>;
|
|
|
|
nome: ColumnType<string, string, string>;
|
|
|
|
sigla: ColumnType<string, string, string>;
|
|
}
|
|
|
|
export type Provincie = Selectable<ProvincieTable>;
|
|
|
|
export type NewProvincie = Insertable<ProvincieTable>;
|
|
|
|
export type ProvincieUpdate = Updateable<ProvincieTable>;
|
|
|
|
export const provincieId = z.number().transform(value => value as ProvincieId);
|
|
|
|
export const ProvincieSchema = z.object({
|
|
id: provincieId,
|
|
nome: z.string(),
|
|
sigla: z.string(),
|
|
});
|
|
|
|
export const NewProvincieSchema = z.object({
|
|
id: provincieId.optional(),
|
|
nome: z.string(),
|
|
sigla: z.string(),
|
|
});
|
|
|
|
export const ProvincieUpdateSchema = z.object({
|
|
id: provincieId.optional(),
|
|
nome: z.string().optional(),
|
|
sigla: z.string().optional(),
|
|
}); |