You can validate input data using runtime types and validation constraints from the @deepkit/type
module. By specifying the types of parameters in your route handler or controller action, Deepkit automatically deserializes and validates the input data based on the defined types. You can also apply additional validation constraints using the validation type annotations provided by @deepkit/type
. Here's an example:
import { Positive } from '@deepkit/type'; router.get('/user/:id', (id: number & Positive) => { // id is guaranteed to be a positive number });