Files
ashen-realms/apps/api/src/exchanges/dto/exchange.dto.ts
Bastian Wagner 081c9f83f9 docs
2026-08-22 16:41:47 +02:00

36 lines
750 B
TypeScript

import { Type } from 'class-transformer';
import {
ArrayMaxSize,
ArrayMinSize,
IsArray,
IsInt,
IsString,
Min,
ValidateNested,
} from 'class-validator';
export class ExchangeItemDto {
@IsString()
itemKey!: string;
@IsInt()
@Min(1)
quantity!: number;
}
export class ExchangeRequestDto {
/**
* Item keys and quantities only.
*
* Prices and rewards are never accepted from the client -- the server reads
* them from the exchange rules (slice §8, NPC spec §37.9). The upper bound
* keeps one request from turning into an unbounded row-by-row transaction.
*/
@IsArray()
@ArrayMinSize(1)
@ArrayMaxSize(50)
@ValidateNested({ each: true })
@Type(() => ExchangeItemDto)
items!: ExchangeItemDto[];
}