How to compare a custome Type to an object obtained from Request.body? - Typescript
07:40 13 Nov 2025

I'm trying to verify if a parameter of the req.body respects the Type contraints that I set on the custom type

Example:

searchModel(req: Request, res: Response): Response {
        const modelName: string = req.body.modelName;
        const domain: Array | Domain> | Domain> =
            req.body.domain;
        const condition: Condition = req.body.condition;

        return res.status(200).send();
    }

How can I compare that the content of req.body.conditioncorresponds with the properties of the Condition type:

type Condition = {
    limit?: Number;
    offset?: Number;
    order?: string;
};
node.js typescript types backend ts-node