fix: ensure dates are properly transformed

To correctly transform Date objects from ISO-strings in JSON
to instances, class-transformer requires the `@Type` annotation.

References:
https://github.com/typestack/class-transformer#%D1%81onverting-date-strings-into-date-objects
Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2022-03-05 12:10:41 +01:00 committed by Philip Molares
parent 59a235ebc4
commit 7e8716ec95
8 changed files with 23 additions and 1 deletions

View file

@ -4,6 +4,7 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { ApiProperty } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { IsDate, IsNumber, IsString } from 'class-validator';
import { BaseDto } from '../utils/base.dto.';
@ -38,6 +39,7 @@ export class RevisionDto extends BaseDto {
* @example "2020-12-01 12:23:34"
*/
@IsDate()
@Type(() => Date)
@ApiProperty()
createdAt: Date;
}