Open
Description
I was trying to make a form builder validation for backend service.
In this i have data occur dependant on the user choice. As Further input depends on previous choices i have conditional fields that need to be present e.g.
{
vehicleType: "truck" | "car"
carData?: "car Specific Props"
truckdata?: "TruckSpecific Props"
}
The problem:
With ValidateIf i could check that the either carData or truckData is present based on vehicleData.
But it still leaves me with the security breach that teh other one is not type checked at and therefore prune to inject any data in the json.
e.g.
{
vehicleType: "truck",
truckData: "TruckData"
carData: "Mailicious Json" β
}
Is there any clean and secure solution to this problem with class-validator?