add dto validation and swagger schemas

This commit is contained in:
2026-05-12 16:17:39 +03:30
parent abb387e743
commit 460537090b
21 changed files with 510 additions and 0 deletions
@@ -1,9 +1,31 @@
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IsBoolean, IsInt, IsNumber, IsOptional, IsUUID, Max, Min } from 'class-validator';
export class CreateBusinessServiceDto {
@ApiProperty({ format: 'uuid' })
@IsUUID()
businessId!: string;
@ApiProperty({ format: 'uuid' })
@IsUUID()
serviceTemplateId!: string;
/** قیمت به واحد پول (عدد اعشاری مجاز است) */
@ApiProperty({ example: 100000 })
@IsNumber({ maxDecimalPlaces: 2 })
@Min(0)
price!: number;
/** اگر خالی باشد از template.defaultDurationMinutes استفاده می‌شود */
@ApiPropertyOptional({ example: 30, nullable: true })
@IsOptional()
@IsInt()
@Min(1)
@Max(1440)
durationMinutes?: number | null;
@ApiPropertyOptional({ example: true })
@IsOptional()
@IsBoolean()
isActive?: boolean;
}
@@ -1,6 +1,27 @@
import { ApiPropertyOptional } from '@nestjs/swagger';
import { IsBoolean, IsInt, IsNumber, IsOptional, IsUUID, Max, Min } from 'class-validator';
export class UpdateBusinessServiceDto {
@ApiPropertyOptional({ format: 'uuid' })
@IsOptional()
@IsUUID()
serviceTemplateId?: string;
@ApiPropertyOptional({ example: 100000 })
@IsOptional()
@IsNumber({ maxDecimalPlaces: 2 })
@Min(0)
price?: number;
@ApiPropertyOptional({ example: 30, nullable: true })
@IsOptional()
@IsInt()
@Min(1)
@Max(1440)
durationMinutes?: number | null;
@ApiPropertyOptional({ example: true })
@IsOptional()
@IsBoolean()
isActive?: boolean;
}