pos-be/src/modules/item-related/time-group/infrastructure/dto/time-group.dto.ts

48 lines
1.4 KiB
TypeScript

import { BaseStatusDto } from 'src/core/modules/infrastructure/dto/base-status.dto';
import { TimeGroupEntity } from '../../domain/entities/time-group.entity';
import { IsString, ValidateIf } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';
export class CreateTimeGroupDto
extends BaseStatusDto
implements TimeGroupEntity
{
@ApiProperty({ name: 'name', required: true, example: 'Morning' })
@IsString()
name: string;
@ApiProperty({ name: 'start_time', required: true, example: '09:00' })
@IsString()
start_time: string;
@ApiProperty({ name: 'end_time', required: true, example: '10:00' })
@IsString()
end_time: string;
@ApiProperty({ name: 'max_usage_time', required: true, example: '10:30' })
@IsString()
max_usage_time: string;
}
export class EditTimeGroupDto extends BaseStatusDto implements TimeGroupEntity {
@ApiProperty({ name: 'name', example: 'Morning' })
@IsString()
@ValidateIf((body) => body.name)
name: string;
@ApiProperty({ name: 'start_time', example: '09:00' })
@IsString()
@ValidateIf((body) => body.start_time)
start_time: string;
@ApiProperty({ name: 'end_time', example: '10:00' })
@IsString()
@ValidateIf((body) => body.end_time)
end_time: string;
@ApiProperty({ name: 'max_usage_time', example: '10:30' })
@IsString()
@ValidateIf((body) => body.max_usage_time)
max_usage_time: string;
}