fix(server): correct person birth date across timezones (#11369)

* fix(server): correct person birth date across timezones

* fix test

* update e2e tests

* use Optional decorator
This commit is contained in:
Michel Heusschen
2024-07-30 01:52:04 +02:00
committed by GitHub
parent ebc71e428d
commit 434bcec5cc
7 changed files with 132 additions and 18 deletions

View File

@@ -1,11 +1,11 @@
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { IsArray, IsInt, IsNotEmpty, IsString, Max, MaxDate, Min, ValidateNested } from 'class-validator';
import { IsArray, IsInt, IsNotEmpty, IsString, Max, Min, ValidateNested } from 'class-validator';
import { PropertyLifecycle } from 'src/decorators';
import { AuthDto } from 'src/dtos/auth.dto';
import { AssetFaceEntity } from 'src/entities/asset-face.entity';
import { PersonEntity } from 'src/entities/person.entity';
import { Optional, ValidateBoolean, ValidateDate, ValidateUUID } from 'src/validation';
import { IsDateStringFormat, MaxDateString, Optional, ValidateBoolean, ValidateUUID } from 'src/validation';
export class PersonCreateDto {
/**
@@ -19,9 +19,11 @@ export class PersonCreateDto {
* Person date of birth.
* Note: the mobile app cannot currently set the birth date to null.
*/
@MaxDate(() => new Date(), { message: 'Birth date cannot be in the future' })
@ValidateDate({ optional: true, nullable: true, format: 'date' })
birthDate?: Date | null;
@ApiProperty({ format: 'date' })
@MaxDateString(() => new Date(), { message: 'Birth date cannot be in the future' })
@IsDateStringFormat('yyyy-MM-dd')
@Optional({ nullable: true })
birthDate?: string | null;
/**
* Person visibility
@@ -84,7 +86,7 @@ export class PersonResponseDto {
id!: string;
name!: string;
@ApiProperty({ format: 'date' })
birthDate!: Date | null;
birthDate!: string | null;
thumbnailPath!: string;
isHidden!: boolean;
@PropertyLifecycle({ addedAt: 'v1.107.0' })