Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

145
Views
Express Typescript Prevent Unwanted Data In Post Request

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:

enter image description here

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?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!