From d7fe7a95c725e52b40c2421f23eaefe38812037c Mon Sep 17 00:00:00 2001 From: David Mehren Date: Sun, 26 Jul 2020 20:57:51 +0200 Subject: [PATCH] Add DTOs for notes and note authorship Signed-off-by: David Mehren --- src/notes/note-authorship.dto.ts | 17 +++++++++++++++++ src/notes/note.dto.ts | 15 +++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 src/notes/note-authorship.dto.ts create mode 100644 src/notes/note.dto.ts diff --git a/src/notes/note-authorship.dto.ts b/src/notes/note-authorship.dto.ts new file mode 100644 index 000000000..9c9252da0 --- /dev/null +++ b/src/notes/note-authorship.dto.ts @@ -0,0 +1,17 @@ +import { IsDate, IsNumber, IsString, Min } from 'class-validator'; +import { UserInfoDto } from '../users/user-info.dto'; + +export class NoteAuthorshipDto { + @IsString() + userName: UserInfoDto['userName']; + @IsNumber() + @Min(0) + startPos: number; + @IsNumber() + @Min(0) + endPos: number; + @IsDate() + createdAt: Date; + @IsDate() + updatedAt: Date; +} diff --git a/src/notes/note.dto.ts b/src/notes/note.dto.ts new file mode 100644 index 000000000..40b209644 --- /dev/null +++ b/src/notes/note.dto.ts @@ -0,0 +1,15 @@ +import { IsArray, IsString, ValidateNested } from 'class-validator'; +import { NoteAuthorshipDto } from './note-authorship.dto'; +import { NoteMetadataDto } from './note-metadata.dto'; + +export class NoteDto { + @IsString() + content: string; + + @ValidateNested() + metdata: NoteMetadataDto; + + @IsArray() + @ValidateNested({ each: true }) + editedByAtPosition: NoteAuthorshipDto[]; +}