mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-15 18:27:05 +00:00
Refactor class-validator imports in community DTOs
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
import { ApiProperty } from '@nestjs/swagger';
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
import { IsNotEmpty, IsString, IsOptional } from 'class-validator';
|
import { IsNotEmpty, IsString } from 'class-validator';
|
||||||
|
|
||||||
export class AddCommunityDto {
|
export class AddCommunityDto {
|
||||||
@ApiProperty({
|
@ApiProperty({
|
||||||
@ -10,14 +10,6 @@ export class AddCommunityDto {
|
|||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
public spaceName: string;
|
public spaceName: string;
|
||||||
|
|
||||||
@ApiProperty({
|
|
||||||
description: 'parentUuid',
|
|
||||||
required: false,
|
|
||||||
})
|
|
||||||
@IsString()
|
|
||||||
@IsOptional()
|
|
||||||
public parentUuid?: string;
|
|
||||||
|
|
||||||
constructor(dto: Partial<AddCommunityDto>) {
|
constructor(dto: Partial<AddCommunityDto>) {
|
||||||
Object.assign(this, dto);
|
Object.assign(this, dto);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,13 @@
|
|||||||
import { ApiProperty } from '@nestjs/swagger';
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
import { IsNotEmpty, IsString } from 'class-validator';
|
import { Transform } from 'class-transformer';
|
||||||
|
import {
|
||||||
|
IsBoolean,
|
||||||
|
IsInt,
|
||||||
|
IsNotEmpty,
|
||||||
|
IsOptional,
|
||||||
|
IsString,
|
||||||
|
Min,
|
||||||
|
} from 'class-validator';
|
||||||
|
|
||||||
export class GetCommunityDto {
|
export class GetCommunityDto {
|
||||||
@ApiProperty({
|
@ApiProperty({
|
||||||
@ -10,3 +18,34 @@ export class GetCommunityDto {
|
|||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
public communityUuid: string;
|
public communityUuid: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class GetCommunityChildDto {
|
||||||
|
@ApiProperty({ example: 1, description: 'Page number', required: true })
|
||||||
|
@IsInt({ message: 'Page must be a number' })
|
||||||
|
@Min(1, { message: 'Page must not be less than 1' })
|
||||||
|
@IsNotEmpty()
|
||||||
|
public page: number;
|
||||||
|
|
||||||
|
@ApiProperty({
|
||||||
|
example: 10,
|
||||||
|
description: 'Number of items per page',
|
||||||
|
required: true,
|
||||||
|
})
|
||||||
|
@IsInt({ message: 'Page size must be a number' })
|
||||||
|
@Min(1, { message: 'Page size must not be less than 1' })
|
||||||
|
@IsNotEmpty()
|
||||||
|
public pageSize: number;
|
||||||
|
|
||||||
|
@ApiProperty({
|
||||||
|
example: true,
|
||||||
|
description: 'Flag to determine whether to fetch full hierarchy',
|
||||||
|
required: false,
|
||||||
|
default: false,
|
||||||
|
})
|
||||||
|
@IsOptional()
|
||||||
|
@IsBoolean()
|
||||||
|
@Transform((value) => {
|
||||||
|
return value.obj.includeSubSpaces === 'true';
|
||||||
|
})
|
||||||
|
public includeSubSpaces: boolean = false;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user