-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feat/backend validation #26
Conversation
WalkthroughThe changes introduced in this commit primarily revolve around enhancing data validation and refining data types in the user module of a NestJS application. The updates include the implementation of global validation, addition of validation decorators to the Changes
Poem
TipsChat with CodeRabbit Bot (
|
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files ignored due to filter (2)
- backend/package.json
- backend/yarn.lock
Files selected for processing (3)
- backend/src/main.ts (1 hunks)
- backend/src/user/dto/create-user.dto.ts (1 hunks)
- backend/src/user/user.controller.ts (2 hunks)
Files skipped from review due to trivial changes (1)
- backend/src/main.ts
Additional comments: 8
backend/src/user/dto/create-user.dto.ts (4)
1-9: The import statements for the validation decorators and
ApiPropertyOptional
are correctly placed and imported from the right modules.12-21: The
CreateUserDto
class is correctly decorated with validation decorators to enforce email format, non-empty value, string type, and maximum length. TheApiProperty
decorator is also correctly used to provide additional metadata for Swagger.23-31: The
name
property of theCreateUserDto
class is correctly decorated with validation decorators to enforce string type, optional value, minimum length, and maximum length. TheApiPropertyOptional
decorator is also correctly used to provide additional metadata for Swagger.33-38: The
password
property of theCreateUserDto
class is correctly decorated with validation decorators to enforce non-empty value, string type, minimum length, and maximum length. TheApiProperty
decorator is also correctly used to provide additional metadata for Swagger.backend/src/user/user.controller.ts (4)
6-10: The import of
ParseIntPipe
is correct and necessary for the changes in this file.39-44: The
findOne
function now correctly expects theid
parameter to be of typenumber
instead ofstring
. TheParseIntPipe
is correctly used to enforce this.46-50: The
update
function now correctly expects theid
parameter to be of typenumber
instead ofstring
. TheParseIntPipe
is correctly used to enforce this.52-56: The
remove
function now correctly expects theid
parameter to be of typenumber
instead ofstring
. TheParseIntPipe
is correctly used to enforce this.Please ensure that all calls to these functions throughout the codebase have been updated to match the new signatures.
Prismaの公式チュートリアルPart2でやった内容を反映させました。
https://www.prisma.io/blog/nestjs-prisma-validation-7D056s1kOla1
こんな感じでレスポンスでvalidationの結果が返ってきます。
Summary by CodeRabbit