public-simulation.dto.ts 842 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { Transform } from 'class-transformer';
  2. import {
  3. ArrayMinSize,
  4. IsArray,
  5. IsOptional,
  6. IsString,
  7. IsUrl,
  8. Length,
  9. Matches,
  10. } from 'class-validator';
  11. const CODE_PATTERN = /^[A-Z0-9]{8}$/;
  12. export class PublicSimulationCodeQueryDto {
  13. @IsOptional()
  14. @Transform(({ value }) =>
  15. typeof value === 'string' ? value.trim().toUpperCase() : value,
  16. )
  17. @IsString()
  18. @Length(8, 8)
  19. @Matches(CODE_PATTERN)
  20. code?: string;
  21. }
  22. export class CreatePublicSimulationDto {
  23. @Transform(({ value }) =>
  24. typeof value === 'string' ? value.trim().toUpperCase() : value,
  25. )
  26. @IsString()
  27. @Length(8, 8)
  28. @Matches(CODE_PATTERN)
  29. inviteCode!: string;
  30. @IsUrl()
  31. originImage!: string;
  32. @IsArray()
  33. @ArrayMinSize(1)
  34. @IsString({ each: true })
  35. templateIds!: string[];
  36. @IsOptional()
  37. @IsString()
  38. simulateRemark?: string;
  39. }