The context of the question is a nestjs app, where I'd like to transform a request payload to a different shape, and along with that, verify a certain property on the payload, but then remove it after validation. So, a request payload of:
{ "reqType": "foo", "source": "001", "target": "xyz"}
would be validated iff reqType == "foo", then potentially mapped (source->from, target->to), so that the resulting business object is sth like:
{from: "001", to: "xyz"}
Any hints on how that can be done, using a single annotated DTO?
Thanks
You can declare a factory function in your dto and invoke it in controller, for example: