tachijs-validated-body

1.0.0-1 • Public • Published

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

Package Sidebar

Install

npm i tachijs-validated-body

Weekly Downloads

7

Version

1.0.0-1

License

MIT

Unpacked Size

4.28 kB

Total Files

6

Last publish

Collaborators

  • rokt33r