Skip to content

Commit

Permalink
Merge pull request #156 from chingu-x/fix/form-response-boolean
Browse files Browse the repository at this point in the history
Fix form responses giving error and not inserting values when the boolean value is false
  • Loading branch information
cherylli authored May 22, 2024
2 parents 81584ca + 2aeec5f commit 010170d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Another example [here](https://co-pilot.dev/changelog)
- Fix a bug in PATCH /meetings/{meetingId}/forms/{formId} where it's not accepting an array of responese (updated validation pipe, service, and tests) ([#121](https://github.com/chingu-x/chingu-dashboard-be/pull/121))
- Fix unit tests where mocked req doesn't match new CustomRequest type ([#122](https://github.com/chingu-x/chingu-dashboard-be/pull/122))
- Fix bug with reading roles after reseeding causes the db to not recognize the tokens stored by the user's browser ([#134](https://github.com/chingu-x/chingu-dashboard-be/pull/134))
- Fix form responses giving error and not inserting values when the boolean value is false ([#156](https://github.com/chingu-x/chingu-dashboard-be/pull/156))

### Removed

Expand Down
2 changes: 1 addition & 1 deletion src/global/global.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class GlobalService {
...(v.numeric
? { numeric: v.numeric }
: { numeric: null }),
...(v.boolean
...(v.boolean !== undefined
? { boolean: v.boolean }
: { boolean: null }),
...(v.optionChoiceId
Expand Down
2 changes: 1 addition & 1 deletion src/pipes/form-input-validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class FormInputValidationPipe implements PipeTransform {
if (
!v.text &&
!v.numeric &&
!v.boolean &&
v.boolean === undefined &&
!v.optionChoiceId
)
throw new BadRequestException(
Expand Down
12 changes: 11 additions & 1 deletion src/sprints/dto/create-checkin-form.dto.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { FormResponseDto } from "../../global/dtos/FormResponse.dto";
import { ApiProperty } from "@nestjs/swagger";
import { IsArray, IsNotEmpty, ValidateNested } from "class-validator";
import {
IsArray,
IsNotEmpty,
IsNumber,
Max,
Min,
ValidateNested,
} from "class-validator";
import { Type } from "class-transformer";

export class CreateCheckinFormDto {
Expand All @@ -16,6 +23,9 @@ export class CreateCheckinFormDto {
example: 1,
})
@IsNotEmpty()
@IsNumber()
@Min(1)
@Max(6)
sprintId: number;

@ApiProperty({
Expand Down
2 changes: 0 additions & 2 deletions src/sprints/sprints.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -568,8 +568,6 @@ export class SprintsService {
responsesArray,
);

// TODO: do we need to check if sprintID is a reasonable sprint Id?

try {
const checkinSubmission = await this.prisma.$transaction(
async (tx) => {
Expand Down

0 comments on commit 010170d

Please sign in to comment.