Add DTOs for notes and note authorship

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2020-07-26 20:57:51 +02:00
parent 735980da7c
commit 11f6358516
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3
2 changed files with 32 additions and 0 deletions

View file

@ -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;
}

15
src/notes/note.dto.ts Normal file
View file

@ -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[];
}