fix(server): non-nullable IsOptional (#3939)

* custom `IsOptional`

* added link to source

* formatting

* Update server/src/domain/domain.util.ts

Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>

* nullable birth date endpoint

* made `nullable` a property

* formatting

* removed unused dto

* updated decorator arg

* fixed album e2e tests

* add null tests for auth e2e

* add null test for person e2e

* fixed tests

* added null test for user e2e

* removed unusued import

* log key in test name

* chore: add note about mobile not being able to use the endpoint

---------

Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
This commit is contained in:
Mert
2023-09-01 12:40:00 -04:00
committed by GitHub
parent ca35e5557b
commit 9539a361e4
43 changed files with 271 additions and 243 deletions

View File

@@ -1,87 +1,87 @@
import { AssetType } from '@app/infra/entities';
import { Transform } from 'class-transformer';
import { IsArray, IsBoolean, IsEnum, IsNotEmpty, IsOptional, IsString } from 'class-validator';
import { toBoolean } from '../../domain.util';
import { IsArray, IsBoolean, IsEnum, IsNotEmpty, IsString } from 'class-validator';
import { toBoolean, Optional } from '../../domain.util';
export class SearchDto {
@IsString()
@IsNotEmpty()
@IsOptional()
@Optional()
q?: string;
@IsString()
@IsNotEmpty()
@IsOptional()
@Optional()
query?: string;
@IsBoolean()
@IsOptional()
@Optional()
@Transform(toBoolean)
clip?: boolean;
@IsEnum(AssetType)
@IsOptional()
@Optional()
type?: AssetType;
@IsBoolean()
@IsOptional()
@Optional()
@Transform(toBoolean)
isFavorite?: boolean;
@IsBoolean()
@IsOptional()
@Optional()
@Transform(toBoolean)
isArchived?: boolean;
@IsString()
@IsNotEmpty()
@IsOptional()
@Optional()
'exifInfo.city'?: string;
@IsString()
@IsNotEmpty()
@IsOptional()
@Optional()
'exifInfo.state'?: string;
@IsString()
@IsNotEmpty()
@IsOptional()
@Optional()
'exifInfo.country'?: string;
@IsString()
@IsNotEmpty()
@IsOptional()
@Optional()
'exifInfo.make'?: string;
@IsString()
@IsNotEmpty()
@IsOptional()
@Optional()
'exifInfo.model'?: string;
@IsString()
@IsNotEmpty()
@IsOptional()
@Optional()
'exifInfo.projectionType'?: string;
@IsString({ each: true })
@IsArray()
@IsOptional()
@Optional()
@Transform(({ value }) => value.split(','))
'smartInfo.objects'?: string[];
@IsString({ each: true })
@IsArray()
@IsOptional()
@Optional()
@Transform(({ value }) => value.split(','))
'smartInfo.tags'?: string[];
@IsBoolean()
@IsOptional()
@Optional()
@Transform(toBoolean)
recent?: boolean;
@IsBoolean()
@IsOptional()
@Optional()
@Transform(toBoolean)
motion?: boolean;
}