mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-12-08 20:29:05 +00:00
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:
@@ -1,6 +1,6 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsNotEmpty, IsOptional, IsString } from 'class-validator';
|
||||
import { ValidateUUID } from '../../domain.util';
|
||||
import { IsNotEmpty, IsString } from 'class-validator';
|
||||
import { Optional, ValidateUUID } from '../../domain.util';
|
||||
|
||||
export class CreateAlbumDto {
|
||||
@IsNotEmpty()
|
||||
@@ -9,7 +9,7 @@ export class CreateAlbumDto {
|
||||
albumName!: string;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
description?: string;
|
||||
|
||||
@ValidateUUID({ optional: true, each: true })
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { IsOptional, IsString } from 'class-validator';
|
||||
import { ValidateUUID } from '../../domain.util';
|
||||
import { IsString } from 'class-validator';
|
||||
import { ValidateUUID, Optional } from '../../domain.util';
|
||||
|
||||
export class UpdateAlbumDto {
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
@IsString()
|
||||
albumName?: string;
|
||||
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
@IsString()
|
||||
description?: string;
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Transform } from 'class-transformer';
|
||||
import { IsBoolean, IsOptional } from 'class-validator';
|
||||
import { toBoolean } from '../../domain.util';
|
||||
import { IsBoolean } from 'class-validator';
|
||||
import { toBoolean, Optional } from '../../domain.util';
|
||||
|
||||
export class AlbumInfoDto {
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
@IsBoolean()
|
||||
@Transform(toBoolean)
|
||||
withoutAssets?: boolean;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { Transform } from 'class-transformer';
|
||||
import { IsBoolean, IsOptional } from 'class-validator';
|
||||
import { toBoolean, ValidateUUID } from '../../domain.util';
|
||||
import { IsBoolean } from 'class-validator';
|
||||
import { toBoolean, ValidateUUID, Optional } from '../../domain.util';
|
||||
|
||||
export class GetAlbumsDto {
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
@IsBoolean()
|
||||
@Transform(toBoolean)
|
||||
@ApiProperty()
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { IsNotEmpty, IsOptional, IsString } from 'class-validator';
|
||||
|
||||
import { IsNotEmpty, IsString } from 'class-validator';
|
||||
import { Optional } from '../domain.util';
|
||||
export class APIKeyCreateDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
name?: string;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
import { AssetType } from '@app/infra/entities';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { Transform } from 'class-transformer';
|
||||
import { IsBoolean, IsOptional } from 'class-validator';
|
||||
import { toBoolean } from '../../domain.util';
|
||||
import { IsBoolean } from 'class-validator';
|
||||
import { toBoolean, Optional } from '../../domain.util';
|
||||
import { AssetStats } from '../asset.repository';
|
||||
|
||||
export class AssetStatsDto {
|
||||
@IsBoolean()
|
||||
@Transform(toBoolean)
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
isArchived?: boolean;
|
||||
|
||||
@IsBoolean()
|
||||
@Transform(toBoolean)
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
isFavorite?: boolean;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import { IsBoolean, IsOptional } from 'class-validator';
|
||||
import { IsBoolean } from 'class-validator';
|
||||
import { BulkIdsDto } from '../response-dto';
|
||||
import { Optional } from '../../domain.util';
|
||||
|
||||
export class AssetBulkUpdateDto extends BulkIdsDto {
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
@IsBoolean()
|
||||
isFavorite?: boolean;
|
||||
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
@IsBoolean()
|
||||
isArchived?: boolean;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsInt, IsOptional, IsPositive } from 'class-validator';
|
||||
import { ValidateUUID } from '../../domain.util';
|
||||
import { IsInt, IsPositive } from 'class-validator';
|
||||
import { Optional, ValidateUUID } from '../../domain.util';
|
||||
|
||||
export class DownloadInfoDto {
|
||||
@ValidateUUID({ each: true, optional: true })
|
||||
@@ -14,7 +14,7 @@ export class DownloadInfoDto {
|
||||
|
||||
@IsInt()
|
||||
@IsPositive()
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
@ApiProperty({ type: 'integer' })
|
||||
archiveSize?: number;
|
||||
}
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { Transform, Type } from 'class-transformer';
|
||||
import { IsBoolean, IsDate, IsOptional } from 'class-validator';
|
||||
import { toBoolean } from '../../domain.util';
|
||||
import { IsBoolean, IsDate } from 'class-validator';
|
||||
import { toBoolean, Optional } from '../../domain.util';
|
||||
|
||||
export class MapMarkerDto {
|
||||
@ApiProperty()
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
@IsBoolean()
|
||||
@Transform(toBoolean)
|
||||
isFavorite?: boolean;
|
||||
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
@IsDate()
|
||||
@Type(() => Date)
|
||||
fileCreatedAfter?: Date;
|
||||
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
@IsDate()
|
||||
@Type(() => Date)
|
||||
fileCreatedBefore?: Date;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { Transform } from 'class-transformer';
|
||||
import { IsBoolean, IsEnum, IsNotEmpty, IsOptional, IsString } from 'class-validator';
|
||||
import { toBoolean, ValidateUUID } from '../../domain.util';
|
||||
import { IsBoolean, IsEnum, IsNotEmpty, IsString } from 'class-validator';
|
||||
import { toBoolean, ValidateUUID, Optional } from '../../domain.util';
|
||||
import { TimeBucketSize } from '../asset.repository';
|
||||
|
||||
export class TimeBucketDto {
|
||||
@@ -19,12 +19,12 @@ export class TimeBucketDto {
|
||||
@ValidateUUID({ optional: true })
|
||||
personId?: string;
|
||||
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
@IsBoolean()
|
||||
@Transform(toBoolean)
|
||||
isArchived?: boolean;
|
||||
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
@IsBoolean()
|
||||
@Transform(toBoolean)
|
||||
isFavorite?: boolean;
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { EntityType } from '@app/infra/entities';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { Type } from 'class-transformer';
|
||||
import { IsDate, IsEnum, IsOptional, IsUUID } from 'class-validator';
|
||||
import { IsDate, IsEnum, IsUUID } from 'class-validator';
|
||||
import { Optional } from '../domain.util';
|
||||
|
||||
export class AuditDeletesDto {
|
||||
@IsDate()
|
||||
@@ -12,7 +13,7 @@ export class AuditDeletesDto {
|
||||
@IsEnum(EntityType)
|
||||
entityType!: EntityType;
|
||||
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
@IsUUID('4')
|
||||
@ApiProperty({ format: 'uuid' })
|
||||
userId?: string;
|
||||
|
||||
@@ -4,8 +4,9 @@ import { IsEmail, IsNotEmpty, IsString } from 'class-validator';
|
||||
|
||||
export class LoginCredentialDto {
|
||||
@IsEmail({ require_tld: false })
|
||||
@Transform(({ value }) => value?.toLowerCase())
|
||||
@IsNotEmpty()
|
||||
@ApiProperty({ example: 'testuser@email.com' })
|
||||
@Transform(({ value }) => value.toLowerCase())
|
||||
email!: string;
|
||||
|
||||
@IsString()
|
||||
|
||||
@@ -4,8 +4,9 @@ import { IsEmail, IsNotEmpty, IsString } from 'class-validator';
|
||||
|
||||
export class SignUpDto {
|
||||
@IsEmail({ require_tld: false })
|
||||
@Transform(({ value }) => value?.toLowerCase())
|
||||
@IsNotEmpty()
|
||||
@ApiProperty({ example: 'testuser@email.com' })
|
||||
@Transform(({ value }) => value.toLowerCase())
|
||||
email!: string;
|
||||
|
||||
@IsString()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { applyDecorators } from '@nestjs/common';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsArray, IsNotEmpty, IsOptional, IsString, IsUUID } from 'class-validator';
|
||||
import { IsArray, IsNotEmpty, IsOptional, IsString, IsUUID, ValidationOptions, ValidateIf } from 'class-validator';
|
||||
import { basename, extname } from 'node:path';
|
||||
import sanitize from 'sanitize-filename';
|
||||
|
||||
@@ -13,7 +13,7 @@ export function ValidateUUID({ optional, each }: Options = { optional: false, ea
|
||||
return applyDecorators(
|
||||
IsUUID('4', { each }),
|
||||
ApiProperty({ format: 'uuid' }),
|
||||
optional ? IsOptional() : IsNotEmpty(),
|
||||
optional ? Optional() : IsNotEmpty(),
|
||||
each ? IsArray() : IsString(),
|
||||
);
|
||||
}
|
||||
@@ -92,3 +92,23 @@ export async function* usePagination<T>(
|
||||
yield result.items;
|
||||
}
|
||||
}
|
||||
|
||||
export interface OptionalOptions extends ValidationOptions {
|
||||
nullable?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if value is missing and if so, ignores all validators.
|
||||
*
|
||||
* @param validationOptions {@link OptionalOptions}
|
||||
*
|
||||
* @see IsOptional exported from `class-validator.
|
||||
*/
|
||||
// https://stackoverflow.com/a/71353929
|
||||
export function Optional({ nullable, ...validationOptions }: OptionalOptions = {}) {
|
||||
if (nullable === true) {
|
||||
return IsOptional(validationOptions);
|
||||
}
|
||||
|
||||
return ValidateIf((obj: any, v: any) => v !== undefined, validationOptions);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsBoolean, IsEnum, IsNotEmpty, IsOptional } from 'class-validator';
|
||||
import { IsBoolean, IsEnum, IsNotEmpty } from 'class-validator';
|
||||
import { JobCommand, QueueName } from './job.constants';
|
||||
import { Optional } from '../domain.util';
|
||||
|
||||
export class JobIdParamDto {
|
||||
@IsNotEmpty()
|
||||
@@ -15,7 +16,7 @@ export class JobCommandDto {
|
||||
@ApiProperty({ type: 'string', enum: JobCommand, enumName: 'JobCommand' })
|
||||
command!: JobCommand;
|
||||
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
@IsBoolean()
|
||||
force!: boolean;
|
||||
}
|
||||
|
||||
@@ -1,47 +1,38 @@
|
||||
import { AssetFaceEntity, PersonEntity } from '@app/infra/entities';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { Transform, Type } from 'class-transformer';
|
||||
import {
|
||||
IsArray,
|
||||
IsBoolean,
|
||||
IsDate,
|
||||
IsNotEmpty,
|
||||
IsOptional,
|
||||
IsString,
|
||||
ValidateIf,
|
||||
ValidateNested,
|
||||
} from 'class-validator';
|
||||
import { toBoolean, ValidateUUID } from '../domain.util';
|
||||
import { IsArray, IsBoolean, IsDate, IsNotEmpty, IsString, ValidateNested } from 'class-validator';
|
||||
import { Optional, toBoolean, ValidateUUID } from '../domain.util';
|
||||
|
||||
export class PersonUpdateDto {
|
||||
/**
|
||||
* Person name.
|
||||
*/
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
@IsString()
|
||||
name?: string;
|
||||
|
||||
/**
|
||||
* Person date of birth.
|
||||
* Note: the mobile app cannot currently set the birth date to null.
|
||||
*/
|
||||
@IsOptional()
|
||||
@Optional({ nullable: true })
|
||||
@IsDate()
|
||||
@Type(() => Date)
|
||||
@ValidateIf((value) => value !== null)
|
||||
@ApiProperty({ format: 'date' })
|
||||
birthDate?: Date | null;
|
||||
|
||||
/**
|
||||
* Asset is used to get the feature face thumbnail.
|
||||
*/
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
@IsString()
|
||||
featureFaceAssetId?: string;
|
||||
|
||||
/**
|
||||
* Person visibility
|
||||
*/
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
@IsBoolean()
|
||||
isHidden?: boolean;
|
||||
}
|
||||
@@ -53,43 +44,13 @@ export class PeopleUpdateDto {
|
||||
people!: PeopleUpdateItem[];
|
||||
}
|
||||
|
||||
export class PeopleUpdateItem {
|
||||
export class PeopleUpdateItem extends PersonUpdateDto {
|
||||
/**
|
||||
* Person id.
|
||||
*/
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
id!: string;
|
||||
|
||||
/**
|
||||
* Person name.
|
||||
*/
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
name?: string;
|
||||
|
||||
/**
|
||||
* Person date of birth.
|
||||
*/
|
||||
@IsOptional()
|
||||
@IsDate()
|
||||
@Type(() => Date)
|
||||
@ApiProperty({ format: 'date' })
|
||||
birthDate?: Date | null;
|
||||
|
||||
/**
|
||||
* Asset is used to get the feature face thumbnail.
|
||||
*/
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
featureFaceAssetId?: string;
|
||||
|
||||
/**
|
||||
* Person visibility
|
||||
*/
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
isHidden?: boolean;
|
||||
}
|
||||
|
||||
export class MergePersonDto {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { SharedLinkType } from '@app/infra/entities';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { Type } from 'class-transformer';
|
||||
import { IsBoolean, IsDate, IsEnum, IsOptional, IsString } from 'class-validator';
|
||||
import { ValidateUUID } from '../domain.util';
|
||||
import { IsBoolean, IsDate, IsEnum, IsString } from 'class-validator';
|
||||
import { ValidateUUID, Optional } from '../domain.util';
|
||||
|
||||
export class SharedLinkCreateDto {
|
||||
@IsEnum(SharedLinkType)
|
||||
@@ -16,40 +16,40 @@ export class SharedLinkCreateDto {
|
||||
albumId?: string;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
description?: string;
|
||||
|
||||
@IsDate()
|
||||
@Type(() => Date)
|
||||
@IsOptional()
|
||||
@Optional({ nullable: true })
|
||||
expiresAt?: Date | null = null;
|
||||
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
@IsBoolean()
|
||||
allowUpload?: boolean = false;
|
||||
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
@IsBoolean()
|
||||
allowDownload?: boolean = true;
|
||||
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
@IsBoolean()
|
||||
showExif?: boolean = true;
|
||||
}
|
||||
|
||||
export class SharedLinkEditDto {
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
description?: string;
|
||||
|
||||
@IsOptional()
|
||||
@Optional({ nullable: true })
|
||||
expiresAt?: Date | null;
|
||||
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
allowUpload?: boolean;
|
||||
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
allowDownload?: boolean;
|
||||
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
showExif?: boolean;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { Type } from 'class-transformer';
|
||||
import { IsBoolean, IsEnum, IsNotEmpty, IsNumber, IsOptional, IsString, Max, Min } from 'class-validator';
|
||||
import { IsBoolean, IsEnum, IsNotEmpty, IsNumber, IsString, Max, Min } from 'class-validator';
|
||||
import { CLIPMode, ModelType } from '../machine-learning.interface';
|
||||
import { Optional } from '../../domain.util';
|
||||
|
||||
export class ModelConfig {
|
||||
@IsBoolean()
|
||||
@@ -12,7 +13,7 @@ export class ModelConfig {
|
||||
modelName!: string;
|
||||
|
||||
@IsEnum(ModelType)
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
@ApiProperty({ enumName: 'ModelType', enum: ModelType })
|
||||
modelType?: ModelType;
|
||||
}
|
||||
@@ -28,7 +29,7 @@ export class ClassificationConfig extends ModelConfig {
|
||||
|
||||
export class CLIPConfig extends ModelConfig {
|
||||
@IsEnum(CLIPMode)
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
@ApiProperty({ enumName: 'CLIPMode', enum: CLIPMode })
|
||||
mode?: CLIPMode;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { TagType } from '@app/infra/entities';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsEnum, IsNotEmpty, IsOptional, IsString } from 'class-validator';
|
||||
import { IsEnum, IsNotEmpty, IsString } from 'class-validator';
|
||||
import { Optional } from '../domain.util';
|
||||
|
||||
export class CreateTagDto {
|
||||
@IsString()
|
||||
@@ -15,6 +16,6 @@ export class CreateTagDto {
|
||||
|
||||
export class UpdateTagDto {
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
name?: string;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Transform } from 'class-transformer';
|
||||
import { IsBoolean, IsEmail, IsNotEmpty, IsOptional, IsString } from 'class-validator';
|
||||
import { toEmail, toSanitized } from '../../domain.util';
|
||||
import { IsBoolean, IsEmail, IsNotEmpty, IsString } from 'class-validator';
|
||||
import { toEmail, toSanitized, Optional } from '../../domain.util';
|
||||
|
||||
export class CreateUserDto {
|
||||
@IsEmail({ require_tld: false })
|
||||
@@ -19,16 +19,16 @@ export class CreateUserDto {
|
||||
@IsString()
|
||||
lastName!: string;
|
||||
|
||||
@IsOptional()
|
||||
@Optional({ nullable: true })
|
||||
@IsString()
|
||||
@Transform(toSanitized)
|
||||
storageLabel?: string | null;
|
||||
|
||||
@IsOptional()
|
||||
@Optional({ nullable: true })
|
||||
@IsString()
|
||||
externalPath?: string | null;
|
||||
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
@IsBoolean()
|
||||
memoriesEnabled?: boolean;
|
||||
}
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { Transform } from 'class-transformer';
|
||||
import { IsBoolean, IsEmail, IsNotEmpty, IsOptional, IsString, IsUUID } from 'class-validator';
|
||||
import { toEmail, toSanitized } from '../../domain.util';
|
||||
import { IsBoolean, IsEmail, IsNotEmpty, IsString, IsUUID } from 'class-validator';
|
||||
import { toEmail, toSanitized, Optional } from '../../domain.util';
|
||||
|
||||
export class UpdateUserDto {
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
@IsEmail({ require_tld: false })
|
||||
@Transform(toEmail)
|
||||
email?: string;
|
||||
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
password?: string;
|
||||
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
firstName?: string;
|
||||
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
lastName?: string;
|
||||
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
@IsString()
|
||||
@Transform(toSanitized)
|
||||
storageLabel?: string;
|
||||
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
@IsString()
|
||||
externalPath?: string;
|
||||
|
||||
@@ -38,15 +38,15 @@ export class UpdateUserDto {
|
||||
@ApiProperty({ format: 'uuid' })
|
||||
id!: string;
|
||||
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
@IsBoolean()
|
||||
isAdmin?: boolean;
|
||||
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
@IsBoolean()
|
||||
shouldChangePassword?: boolean;
|
||||
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
@IsBoolean()
|
||||
memoriesEnabled?: boolean;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { Optional } from '../../domain.util';
|
||||
import { Transform } from 'class-transformer';
|
||||
import { IsBoolean, IsOptional } from 'class-validator';
|
||||
import { IsBoolean } from 'class-validator';
|
||||
|
||||
export class UserCountDto {
|
||||
@IsBoolean()
|
||||
@IsOptional()
|
||||
@Optional()
|
||||
@Transform(({ value }) => value === 'true')
|
||||
/**
|
||||
* When true, return the number of admins accounts
|
||||
|
||||
Reference in New Issue
Block a user