-
Notifications
You must be signed in to change notification settings - Fork 46
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
add create campaign agreements validation #649
Conversation
if any of the 3 agreements for creating campaign are not checked -> throw a HttpException with status 405
✅ Tests will run for this PR. Once they succeed it can be merged. |
!createCampaignApplicationDto.transparencyTermsAccepted || | ||
!createCampaignApplicationDto.personalInformationProcessingAccepted | ||
) { | ||
throw new HttpException('All agreements must be checked', HttpStatus.METHOD_NOT_ALLOWED) |
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.
Method not allowed (405)
is not the appropriate http response to respond with in such scenarios.
We've established some practice to respond with Bad Request (400)
for invalid DTO content, but I suppose you could also respond with Unprocessable Content (422)
. Either of them are semantically fine.
http error code is now 400 in validation for all 3 agreements in create method
changed the error from HttpException to BadRequestException for the agreements validation in create method in campaign-application.service.ts
* add create campaign agreements validation if any of the 3 agreements for creating campaign are not checked -> throw a HttpException with status 405 * fix http error status code in campaign-application.service http error code is now 400 in validation for all 3 agreements in create method * fix throw new BadRequestException changed the error from HttpException to BadRequestException for the agreements validation in create method in campaign-application.service.ts
if any of the 3 agreements for creating campaign are not checked -> throw a HttpException with status 405
add validation if the 3 agreements are checked(true)
add test
update create-campaign-application.dto(acceptTermsAndConditions, transparencyTermsAccepted,personalInformationProcessingAccepted are boolean)
Motivation and context
Testing
Steps to test
New endpoints
Environment
New environment variables:
NEW_ENV_VAR
: env var detailsNew or updated dependencies:
dependency/name
v1.0.0
v2.0.0