Skip to content

Commit

Permalink
fix(api): add Boolean as an orderable property
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoMendes98 committed Sep 26, 2023
1 parent ed80657 commit e5784fa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion libs/common/src/dtos/find-query/find-query-order.dto.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ describe("FindQueryOrderDto", () => {
type: () => String
})
public f!: string | null;
@DtoProperty()
public g!: boolean;
}

const FlatOrderDto = FindQueryOrderDtoOf(FlatDto);
Expand All @@ -38,7 +40,7 @@ describe("FindQueryOrderDto", () => {
it("should be valid", () => {
const orders: Array<InstanceType<typeof FlatOrderDto>> = [
{ a: "asc", b: "desc", c: "asc_nf", d: "desc_nf" },
{ e: "asc_nl", f: "desc_nl" },
{ e: "asc_nl", f: "desc_nl", g: "asc" },
{}
];

Expand Down
2 changes: 1 addition & 1 deletion libs/common/src/dtos/find-query/find-query-order.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function FindQueryOrderDtoOf<T extends object>(dto: Type<T>): Type<Entity

// We suppose that Object is a union or a "bad" type definition
// undefined for null
if ([String, Date, Number, Object, undefined].includes(type as never)) {
if ([Boolean, String, Date, Number, Object, undefined].includes(type as never)) {
decorators.push(IsIn(OrderValues));
} else {
const nestedType = generateOrderClass(type);
Expand Down

0 comments on commit e5784fa

Please sign in to comment.