How do I compare a custom type to an object obtained from req.body? [closed]
I'm trying to verify if a parameter of the req.body respects the type constraints that I set on the custom type. How can I compare if the content of req.body.condition corresponds to the properties of the Condition type? Example: type Condition = { limit?: number; offset?: number; order?: string; }; type Domain = // Domain must be a an Array of field,comparisonOperator,value [field: string, comparisonOperator: string, value: any]; function searchModel(req:any): any { const modelName: string = req?.body?.modelName ?? null; const domain: Array<Array<Array<Domain> | Domain> | Domain> = req.body.d
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.