-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/event validation #19
base: main
Are you sure you want to change the base?
Changes from 6 commits
34b4677
b3e83aa
76a675a
39098df
d3b6244
3102e7a
9c5ce14
4f05111
ef883f1
59eadf9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,4 @@ import { OmitType } from '@nestjs/swagger'; | |
|
||
import { Event } from '../entities/event.entity'; | ||
|
||
export class CreateEventDto extends OmitType(Event, [ | ||
'id', | ||
'categoryId', | ||
'category', | ||
'ownerUserId', | ||
'ownerUser', | ||
'ownerGroupId', | ||
'ownerGroup', | ||
]) {} | ||
export class CreateEventDto extends OmitType(Event, ['id', 'category', 'ownerGroupId', 'ownerUserId']) {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would say we need everything upon creation, but maybe I'm wrong. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,71 @@ | ||
import { Category, Group, Priority, Status, User } from '@prisma/client'; | ||
import { IsDate, IsInt, IsNotEmpty, IsString } from 'class-validator'; | ||
import { Priority, Status } from '@prisma/client'; | ||
import { IsDate, IsDateString, IsEnum, IsInt, IsNotEmpty, IsOptional, IsString } from 'class-validator'; | ||
|
||
export class Category { | ||
@IsInt() | ||
id: number; | ||
|
||
@IsString() | ||
name: string; | ||
balintking marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
@IsString() | ||
@IsOptional() | ||
color: string; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. when optional we could declare as |
||
|
||
@IsString() | ||
@IsOptional() | ||
description: string; | ||
} | ||
export class Event { | ||
@IsInt() | ||
@IsOptional() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. id should not be optional as I see |
||
id: number; | ||
|
||
@IsString() | ||
@IsNotEmpty() | ||
name: string; | ||
|
||
@IsString() | ||
@IsNotEmpty() | ||
@IsOptional() | ||
description: string; | ||
|
||
@IsString() | ||
@IsNotEmpty() | ||
@IsOptional() | ||
location: string; | ||
|
||
@IsDate() | ||
@IsOptional() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. start date is not optional There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you mixed this up with the default values. But this is the entity, this should perfectly mirror what's in the database schema. The default values come handy creating an object and not telling those values. Thats what create dto is for. |
||
startDate: Date; | ||
|
||
@IsDate() | ||
@IsOptional() | ||
endDate: Date; | ||
@IsDate() | ||
|
||
@IsDateString() | ||
@IsOptional() | ||
startTime: Date; | ||
@IsDate() | ||
|
||
@IsDateString() | ||
@IsOptional() | ||
endTime: Date; | ||
|
||
@IsEnum(Priority) | ||
@IsOptional() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. priority is also not optional according to the schema |
||
priority: Priority; | ||
|
||
@IsEnum(Priority) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume this is incorrect There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it should be @IsEnum(Status) |
||
@IsOptional() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not optional |
||
status: Status; | ||
|
||
@IsInt() | ||
@IsOptional() | ||
categoryId: number; | ||
|
||
category: Category; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't need category |
||
|
||
@IsInt() | ||
ownerUserId: number; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. optional |
||
ownerUser: User; | ||
|
||
@IsInt() | ||
ownerGroupId: number; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. optional |
||
ownerGroup: Group; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please resolve the merge conflict (just delete all between <<< and >>> 76...43).