From 57d1fc12bf76803562407b41f2e32e78536dc7a5 Mon Sep 17 00:00:00 2001 From: David Mehren Date: Mon, 31 May 2021 22:04:59 +0200 Subject: [PATCH] EditDto: Clarify that the username can be `null` If the edit was made by a anonymous user, we don't have a username. Signed-off-by: David Mehren --- src/revisions/edit.dto.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/revisions/edit.dto.ts b/src/revisions/edit.dto.ts index 175ae9787..138750ff2 100644 --- a/src/revisions/edit.dto.ts +++ b/src/revisions/edit.dto.ts @@ -4,18 +4,20 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -import { IsDate, IsNumber, IsString, Min } from 'class-validator'; +import { IsDate, IsNumber, IsOptional, IsString, Min } from 'class-validator'; import { UserInfoDto } from '../users/user-info.dto'; -import { ApiProperty } from '@nestjs/swagger'; +import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; export class EditDto { /** * Username of the user who authored this section + * Is `null` if the user is anonymous * @example "john.smith" */ @IsString() - @ApiProperty() - userName: UserInfoDto['userName']; + @IsOptional() + @ApiPropertyOptional() + userName: UserInfoDto['userName'] | null; /** * Character index of the start of this section