mirror of
https://github.com/SyncrowIOT/backend.git
synced 2026-10-26 02:07:55 +00:00
feat: update DEVICE_SPACE_COMMUNITY route and add validation for spaceUuid and communityUuid in DTO
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
IsOptional,
|
||||
IsString,
|
||||
IsUUID,
|
||||
ValidateIf,
|
||||
} from 'class-validator';
|
||||
|
||||
export class GetDeviceBySpaceUuidDto {
|
||||
@@ -66,4 +67,8 @@ export class GetDevicesBySpaceOrCommunityDto {
|
||||
@IsUUID('4', { message: 'Invalid community UUID format' })
|
||||
@IsOptional()
|
||||
communityUuid?: string;
|
||||
|
||||
@ValidateIf((o) => !o.spaceUuid && !o.communityUuid)
|
||||
@IsNotEmpty({ message: 'Either spaceUuid or communityUuid must be provided' })
|
||||
requireEither?: never; // This ensures at least one of them is provided
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user