mirror of
https://github.com/immich-app/immich.git
synced 2026-03-07 10:37:22 +03:00
fix: null validation (#25891)
This commit is contained in:
@@ -73,8 +73,7 @@ export class AssetBulkUpdateDto extends UpdateAssetBase {
|
||||
@ValidateUUID({ each: true, description: 'Asset IDs to update' })
|
||||
ids!: string[];
|
||||
|
||||
@ApiProperty({ description: 'Duplicate asset ID' })
|
||||
@Optional()
|
||||
@ValidateString({ optional: true, nullable: true, description: 'Duplicate ID' })
|
||||
duplicateId?: string | null;
|
||||
|
||||
@ApiProperty({ description: 'Relative time offset in seconds' })
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { IsString } from 'class-validator';
|
||||
import { ArrayMinSize, IsString } from 'class-validator';
|
||||
import { NotificationLevel, NotificationType } from 'src/enum';
|
||||
import { Optional, ValidateBoolean, ValidateDate, ValidateEnum, ValidateUUID } from 'src/validation';
|
||||
import { Optional, ValidateBoolean, ValidateDate, ValidateEnum, ValidateString, ValidateUUID } from 'src/validation';
|
||||
|
||||
export class TestEmailResponseDto {
|
||||
@ApiProperty({ description: 'Email message ID' })
|
||||
@@ -75,20 +75,17 @@ export class NotificationCreateDto {
|
||||
@ValidateEnum({ enum: NotificationType, name: 'NotificationType', optional: true, description: 'Notification type' })
|
||||
type?: NotificationType;
|
||||
|
||||
@ApiProperty({ description: 'Notification title' })
|
||||
@IsString()
|
||||
@ValidateString({ description: 'Notification title' })
|
||||
title!: string;
|
||||
|
||||
@ApiPropertyOptional({ description: 'Notification description' })
|
||||
@IsString()
|
||||
@Optional({ nullable: true })
|
||||
@ValidateString({ optional: true, nullable: true, description: 'Notification description' })
|
||||
description?: string | null;
|
||||
|
||||
@ApiPropertyOptional({ description: 'Additional notification data' })
|
||||
@Optional({ nullable: true })
|
||||
data?: any;
|
||||
|
||||
@ValidateDate({ optional: true, description: 'Date when notification was read' })
|
||||
@ValidateDate({ optional: true, nullable: true, description: 'Date when notification was read' })
|
||||
readAt?: Date | null;
|
||||
|
||||
@ValidateUUID({ description: 'User ID to send notification to' })
|
||||
@@ -96,20 +93,22 @@ export class NotificationCreateDto {
|
||||
}
|
||||
|
||||
export class NotificationUpdateDto {
|
||||
@ValidateDate({ optional: true, description: 'Date when notification was read' })
|
||||
@ValidateDate({ optional: true, nullable: true, description: 'Date when notification was read' })
|
||||
readAt?: Date | null;
|
||||
}
|
||||
|
||||
export class NotificationUpdateAllDto {
|
||||
@ValidateUUID({ each: true, optional: true, description: 'Notification IDs to update' })
|
||||
@ValidateUUID({ each: true, description: 'Notification IDs to update' })
|
||||
@ArrayMinSize(1)
|
||||
ids!: string[];
|
||||
|
||||
@ValidateDate({ optional: true, description: 'Date when notifications were read' })
|
||||
@ValidateDate({ optional: true, nullable: true, description: 'Date when notifications were read' })
|
||||
readAt?: Date | null;
|
||||
}
|
||||
|
||||
export class NotificationDeleteAllDto {
|
||||
@ValidateUUID({ each: true, description: 'Notification IDs to delete' })
|
||||
@ArrayMinSize(1)
|
||||
ids!: string[];
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ export class SharedLinkCreateDto {
|
||||
@IsString()
|
||||
slug?: string | null;
|
||||
|
||||
@ValidateDate({ optional: true, description: 'Expiration date' })
|
||||
@ValidateDate({ optional: true, nullable: true, description: 'Expiration date' })
|
||||
expiresAt?: Date | null = null;
|
||||
|
||||
@ValidateBoolean({ optional: true, description: 'Allow uploads' })
|
||||
|
||||
@@ -9,7 +9,7 @@ export class TagCreateDto {
|
||||
@IsNotEmpty()
|
||||
name!: string;
|
||||
|
||||
@ValidateUUID({ optional: true, description: 'Parent tag ID' })
|
||||
@ValidateUUID({ nullable: true, optional: true, description: 'Parent tag ID' })
|
||||
parentId?: string | null;
|
||||
|
||||
@ApiPropertyOptional({ description: 'Tag color (hex)' })
|
||||
@@ -20,7 +20,7 @@ export class TagCreateDto {
|
||||
|
||||
export class TagUpdateDto {
|
||||
@ApiPropertyOptional({ description: 'Tag color (hex)' })
|
||||
@Optional({ emptyToNull: true })
|
||||
@Optional({ nullable: true, emptyToNull: true })
|
||||
@ValidateHexColor()
|
||||
color?: string | null;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,13 @@ export class UserUpdateMeDto {
|
||||
@IsNotEmpty()
|
||||
name?: string;
|
||||
|
||||
@ValidateEnum({ enum: UserAvatarColor, name: 'UserAvatarColor', optional: true, description: 'Avatar color' })
|
||||
@ValidateEnum({
|
||||
enum: UserAvatarColor,
|
||||
name: 'UserAvatarColor',
|
||||
optional: true,
|
||||
nullable: true,
|
||||
description: 'Avatar color',
|
||||
})
|
||||
avatarColor?: UserAvatarColor | null;
|
||||
}
|
||||
|
||||
@@ -96,9 +102,19 @@ export class UserAdminCreateDto {
|
||||
@IsString()
|
||||
name!: string;
|
||||
|
||||
@ValidateEnum({ enum: UserAvatarColor, name: 'UserAvatarColor', optional: true, description: 'Avatar color' })
|
||||
@ValidateEnum({
|
||||
enum: UserAvatarColor,
|
||||
name: 'UserAvatarColor',
|
||||
optional: true,
|
||||
nullable: true,
|
||||
description: 'Avatar color',
|
||||
})
|
||||
avatarColor?: UserAvatarColor | null;
|
||||
|
||||
@ApiPropertyOptional({ description: 'PIN code' })
|
||||
@PinCode({ optional: true, nullable: true, emptyToNull: true })
|
||||
pinCode?: string | null;
|
||||
|
||||
@ApiPropertyOptional({ description: 'Storage label' })
|
||||
@Optional({ nullable: true })
|
||||
@IsString()
|
||||
@@ -135,7 +151,7 @@ export class UserAdminUpdateDto {
|
||||
password?: string;
|
||||
|
||||
@ApiPropertyOptional({ description: 'PIN code' })
|
||||
@PinCode({ optional: true, emptyToNull: true })
|
||||
@PinCode({ optional: true, nullable: true, emptyToNull: true })
|
||||
pinCode?: string | null;
|
||||
|
||||
@ApiPropertyOptional({ description: 'User name' })
|
||||
@@ -144,7 +160,13 @@ export class UserAdminUpdateDto {
|
||||
@IsNotEmpty()
|
||||
name?: string;
|
||||
|
||||
@ValidateEnum({ enum: UserAvatarColor, name: 'UserAvatarColor', optional: true, description: 'Avatar color' })
|
||||
@ValidateEnum({
|
||||
enum: UserAvatarColor,
|
||||
name: 'UserAvatarColor',
|
||||
optional: true,
|
||||
nullable: true,
|
||||
description: 'Avatar color',
|
||||
})
|
||||
avatarColor?: UserAvatarColor | null;
|
||||
|
||||
@ApiPropertyOptional({ description: 'Storage label' })
|
||||
|
||||
Reference in New Issue
Block a user