targo-backend/src/time-and-attendance/modules/expenses/~misc_deprecated-files/upsert-expense.dto.ts

59 lines
1.5 KiB
TypeScript

// import { Transform, Type } from "class-transformer";
// import {
// IsNumber,
// IsOptional,
// IsString,
// Matches,
// MaxLength,
// Min,
// ValidateIf,
// ValidateNested
// } from "class-validator";
// export class ExpensePayloadDto {
// @IsString()
// type!: string;
// @ValidateIf(o => (o.type ?? '').toUpperCase() !== 'MILEAGE')
// @IsNumber()
// @Min(0)
// amount?: number;
// @ValidateIf(o => (o.type ?? '').toUpperCase() === 'MILEAGE')
// @IsNumber()
// @Min(0)
// mileage?: number;
// @IsString()
// @MaxLength(280)
// @Transform(({ value }) => (typeof value === 'string' ? value.trim() : value))
// comment!: string;
// @IsOptional()
// @Transform(({ value }) => {
// if (value === null || value === undefined || value === '') return undefined;
// if (typeof value === 'number') return value.toString();
// if (typeof value === 'string') {
// const trimmed = value.trim();
// return trimmed.length ? trimmed : undefined;
// }
// return undefined;
// })
// @IsString()
// @Matches(/^\d+$/)
// @MaxLength(255)
// attachment?: string;
// }
// export class UpsertExpenseDto {
// @IsOptional()
// @ValidateNested()
// @Type(()=> ExpensePayloadDto)
// old_expense?: ExpensePayloadDto;
// @IsOptional()
// @ValidateNested()
// @Type(()=> ExpensePayloadDto)
// new_expense?: ExpensePayloadDto;
// }