fix(server): use luxon for maxdate validator (#11651)

This commit is contained in:
Michel Heusschen
2024-08-08 16:02:39 +02:00
committed by GitHub
parent 66f2ac8ce3
commit 4a42a72bd3
3 changed files with 13 additions and 5 deletions

View File

@@ -1,6 +1,7 @@
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { IsArray, IsInt, IsNotEmpty, IsString, Max, Min, ValidateNested } from 'class-validator';
import { DateTime } from 'luxon';
import { PropertyLifecycle } from 'src/decorators';
import { AuthDto } from 'src/dtos/auth.dto';
import { AssetFaceEntity } from 'src/entities/asset-face.entity';
@@ -20,7 +21,7 @@ export class PersonCreateDto {
* Note: the mobile app cannot currently set the birth date to null.
*/
@ApiProperty({ format: 'date' })
@MaxDateString(() => new Date(), { message: 'Birth date cannot be in the future' })
@MaxDateString(() => DateTime.now(), { message: 'Birth date cannot be in the future' })
@IsDateStringFormat('yyyy-MM-dd')
@Optional({ nullable: true })
birthDate?: string | null;