Skip to content

Latest commit

 

History

History
40 lines (29 loc) · 1.12 KB

readme.md

File metadata and controls

40 lines (29 loc) · 1.12 KB

TachiJS validated body

Build Status codecov NPM download Supported by BoostIO

Validate body with class validator!

How to use

Install peer dependencies.

npm i reflect-metadata class-validator class-transformer-validator class-transformer

Replace @reqBody() with @validatedBody().

import { validatedBody } from 'tachijs-validated-body'

class MessageRequestBodyDTO {
  @IsString()
  message: string
}

@controller('/')
class EchoController {
  @httpPost('/')
  // echo(@reqBody() body: unknown) {
  echo(@validatedBody() body: MessageRequestBodyDTO) {
    return body.message
  }
}

License

MIT © Junyoung Choi