Typescript runtime class validation
A library for runtime param validations using typescript decorators
that works with class-validator
library.
Useful when you need to validate parameter data coming from untyped source(i.e http body, and etc...) or when you need to perform complex validations on the input params.
Using the param validation decorator you can declare your validation on the type annotation and leave the validation work to class-validator
Install
npm install --save typescript-class-validator
Examples
;; ; // Will throw class-validator errors on runtimeinstance.methodName; instance.serverControllerEndpoint;
Catching the Validation errors
In order to catch the validation errors you need to check if the errors is instanceof ValidatorError
;
; try catch error