mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-11-26 08:34:55 +00:00
refactor: remove unsed code
This commit is contained in:
@ -1,55 +0,0 @@
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import {
|
||||
IsDateString,
|
||||
IsEnum,
|
||||
IsNotEmpty,
|
||||
IsNumber,
|
||||
IsOptional,
|
||||
IsString,
|
||||
Max,
|
||||
Min,
|
||||
ValidateIf,
|
||||
} from 'class-validator';
|
||||
import { i18nValidationMessage as i18n } from 'nestjs-i18n';
|
||||
import { MoneyRequestFrequency } from '~/money-request/enums';
|
||||
const MIN_REQUESTED_AMOUNT = 0.01;
|
||||
const MAX_REQUESTED_AMOUNT = 1000000;
|
||||
export class CreateMoneyRequestRequestDto {
|
||||
@Min(MIN_REQUESTED_AMOUNT, {
|
||||
message: i18n('validation.Min', { path: 'general', property: 'moneyRequest.requestedAmount' }),
|
||||
})
|
||||
@Max(MAX_REQUESTED_AMOUNT, {
|
||||
message: i18n('validation.Max', { path: 'general', property: 'moneyRequest.requestedAmount' }),
|
||||
})
|
||||
@IsNumber(
|
||||
{ allowNaN: false },
|
||||
{ message: i18n('validation.IsNumber', { path: 'general', property: 'moneyRequest.requestedAmount' }) },
|
||||
)
|
||||
@ApiProperty()
|
||||
requestedAmount!: number;
|
||||
|
||||
@ApiProperty()
|
||||
@IsString({ message: i18n('validation.IsString', { path: 'general', property: 'moneyRequest.message' }) })
|
||||
@IsNotEmpty({ message: i18n('validation.IsNotEmpty', { path: 'general', property: 'moneyRequest.message' }) })
|
||||
message!: string;
|
||||
|
||||
@ApiPropertyOptional({ example: MoneyRequestFrequency.ONE_TIME })
|
||||
@IsEnum(MoneyRequestFrequency, {
|
||||
message: i18n('validation.IsEnum', { path: 'general', property: 'moneyRequest.frequency' }),
|
||||
})
|
||||
@IsOptional()
|
||||
frequency: MoneyRequestFrequency = MoneyRequestFrequency.ONE_TIME;
|
||||
|
||||
@ApiPropertyOptional({ example: '2021-01-01' })
|
||||
@IsDateString(
|
||||
{},
|
||||
{ message: i18n('validation.IsDateString', { path: 'general', property: 'moneyRequest.startDate' }) },
|
||||
)
|
||||
@ValidateIf((o) => o.frequency !== MoneyRequestFrequency.ONE_TIME)
|
||||
startDate?: string;
|
||||
|
||||
@ApiPropertyOptional({ example: '2021-01-01' })
|
||||
@IsDateString({}, { message: i18n('validation.IsDateString', { path: 'general', property: 'moneyRequest.endDate' }) })
|
||||
@IsOptional()
|
||||
endDate?: string;
|
||||
}
|
||||
Reference in New Issue
Block a user