Skip to content

Commit

Permalink
Merge pull request #42 from fagbokforlaget/EP-5623-fix-mongoose-pagin…
Browse files Browse the repository at this point in the history
…ate-to-make-filter-optional

Ep 5623 fix mongoose paginate to make filter optional
  • Loading branch information
espresse authored Jul 3, 2024
2 parents 48fc048 + 6095b46 commit 9728e93
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/input.dto.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ describe('CounterDto', () => {
const errors = await validate(counterDto);
expect(errors.length).toBe(0);
});

it('should allow payload without any filter', async () => {
const payload = {};
const counterDto = plainToClass(CounterDto, payload);
const errors = await validate(counterDto);

expect(errors.length).toBe(0);
});
});

describe('CollectionDto', () => {
Expand Down
1 change: 1 addition & 0 deletions src/input.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class CounterDto {
type: String,
})
@Transform((v: TransformFnParams) => filterQueryToObject(v.value))
@IsOptional()
@IsObject()
readonly filter?: FilterableParameters;
}
Expand Down

0 comments on commit 9728e93

Please sign in to comment.