the post request has content_Name,content_Type, content_Json.
Those are the field that should be sent, but if i add a property ill be able to send a request with an unwanted datafield how can i prevent that:
DTO:
content_name,
content_type,
Content_json,
Json Request (Example) sent
{
"this_field_shouldnt_be_available" : "Zebb"
}
Request received
{
"this_field_shouldnt_be_available" : "Zebb",
content_name: null,
content_type: null,
Content_json: null
}
How can I have an exception to use a "DTO" to only allow the valid data
is it possible without schema? just comparing to DTO?
>Solution :
You can add a middleware with a validation to verify each property key that must exist in the DTO, and then validate the quantity of keys of the DTO assuring that it is not greater than the keys you set to be there