-
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 8 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 |
---|---|---|
@@ -1,35 +1,67 @@ | ||
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 Event { | ||
export class Category { | ||
@IsInt() | ||
id: number; | ||
|
||
@IsString() | ||
@IsNotEmpty() | ||
name: string; | ||
balintking marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
@IsString() | ||
@IsNotEmpty() | ||
color?: string; | ||
|
||
@IsString() | ||
@IsOptional() | ||
description: string; | ||
} | ||
export class Event { | ||
@IsInt() | ||
id: number; | ||
|
||
@IsString() | ||
@IsNotEmpty() | ||
name: string; | ||
|
||
@IsString() | ||
@IsOptional() | ||
description: string; | ||
|
||
@IsString() | ||
@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(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() | ||
categoryId: number; | ||
category: 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.
Omit only id, because that's the only information the database comes up with alone. The owner we should specify.