samchon / nestia

NestJS Helper Libraries + TypeScript OpenAPI generator
https://nestia.io/
MIT License
1.85k stars 95 forks source link

Question: Transform payloads to sanitize userInput #686

Closed DavidVaness closed 8 months ago

DavidVaness commented 1 year ago

Question

Hey @samchon, thanks again for the progress you are making with this lib. When using class transformer I am able to add a transform decorator to sanitize user input. see this example I pulled from Stack overflow

import { ApiProperty } from '@nestjs/swagger';
import { Transform } from 'class-transformer';
import { IsString } from 'class-validator';
import * as sanitizeHtml from 'sanitize-html';

export class ContactInfoDTO {
  @ApiProperty()
  @IsString()
  @Transform((params: TransformFnParams) => sanitizeHtml(params.value))
  public body: string;
}

What is the best way to achieve this while using nestia / typia? Best Regards David

samchon commented 1 year ago

No way in typia. Do it by yourself please.