tachijs-validated-body
v1.0.0-1
Published
Request body validation decorator for tachijs
Downloads
2
Maintainers
Readme
TachiJS validated body
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