import { ApiPropertyOptional } from '@nestjs/swagger'; import { IsBoolean, IsOptional, IsString, Matches, MaxLength, } from 'class-validator'; import { IsOptionalNotNull } from '../../common/validation/is-optional-not-null'; const GROUP_ID_PATTERN = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})?$/i; // PATCH null rule: an omitted field stays unchanged. The switches are NOT // NULL columns, so null on them is a 400. groupId is nullable: null clears // it, and so does "" - the GUI's way of emptying the field. export class UpdateCalendarSyncSettingsDto { @ApiPropertyOptional() @IsOptionalNotNull() @IsBoolean() enabled?: boolean; @ApiPropertyOptional({ type: String, nullable: true, description: 'Objekt-ID der Microsoft-365-Gruppe. Leerer String oder null löscht den GUI-Wert.', }) @IsOptional() @IsString() @MaxLength(100) // An Entra object id (GUID) or "" - the value goes into the Graph URL // path, so nothing else may get through. @Matches(GROUP_ID_PATTERN, { message: 'Gruppen-ID muss die Objekt-ID der Microsoft-365-Gruppe sein (Format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)', }) groupId?: string | null; @ApiPropertyOptional() @IsOptionalNotNull() @IsBoolean() syncTask?: boolean; @ApiPropertyOptional() @IsOptionalNotNull() @IsBoolean() syncInspection?: boolean; @ApiPropertyOptional() @IsOptionalNotNull() @IsBoolean() syncTreatment?: boolean; @ApiPropertyOptional() @IsOptionalNotNull() @IsBoolean() syncFeeding?: boolean; @ApiPropertyOptional() @IsOptionalNotNull() @IsBoolean() syncHarvest?: boolean; @ApiPropertyOptional() @IsOptionalNotNull() @IsBoolean() syncQueenAssignment?: boolean; }