INSIGHT-MVP/packages/crm-service/src/custom-fields/dto/set-custom-field-values.dto.ts
Thomas Reitz aaedf68085 feat(crm): Phase 2.1 Custom Fields — backend + frontend integration
Backend (CRM expert): Custom field definitions CRUD, bulk value upsert,
7 endpoints, Prisma schema with CustomFieldDef + CustomFieldValue tables.

Frontend: Types, API, hooks, admin settings page with field management,
CustomFieldsDisplay for detail pages, CustomFieldsForm for edit modals.
Also fix Vite allowedHosts for insight.xinion.lan.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 18:22:57 +01:00

35 lines
1.2 KiB
TypeScript

// ============================================================
// DTO fuer Custom Fields — Werte setzen (Bulk-Upsert)
// ============================================================
import { IsArray, IsUUID, ValidateNested } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';
import { Type } from 'class-transformer';
export class CustomFieldValueItemDto {
@ApiProperty({ format: 'uuid', description: 'ID der Feld-Definition' })
@IsUUID()
fieldDefId!: string;
@ApiProperty({
description: 'Wert: string | number | boolean | string[] | null',
oneOf: [
{ type: 'string' },
{ type: 'number' },
{ type: 'boolean' },
{ type: 'array', items: { type: 'string' } },
{ nullable: true },
],
})
// HINWEIS: Keine class-validator Dekoration fuer value, da Union-Type.
// Validierung gegen fieldType erfolgt im Service.
value!: string | number | boolean | string[] | null;
}
export class SetCustomFieldValuesDto {
@ApiProperty({ type: [CustomFieldValueItemDto], description: 'Alle Werte fuer eine Entity' })
@IsArray()
@ValidateNested({ each: true })
@Type(() => CustomFieldValueItemDto)
values!: CustomFieldValueItemDto[];
}