When making a post request, the required fields are content_name, content_type, and content_json. However, adding an extra property could result in sending unwanted data. How can this be prevented?
Data Transfer Object (DTO):
content_name,
content_type,
Content_json,
An example of the JSON Request sent:
{
"this_field_shouldnt_be_available" : "Zebb"
}
Request received:
{
"this_field_shouldnt_be_available" : "Zebb",
content_name: null,
content_type: null,
Content_json: null
}
Is there a way to make an exception using a DTO to only allow valid data without needing a schema? Can it be achieved simply by comparing to the DTO?