Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📝 [Proposal]: Add options for active DisallowUnknownFields in the function BodyParser #2858

Open
3 tasks done
solrac97gr opened this issue Feb 13, 2024 · 2 comments
Open
3 tasks done

Comments

@solrac97gr
Copy link
Contributor

solrac97gr commented Feb 13, 2024

Feature Proposal Description

Add options object for active the DisallowUnknownFields in the BodyParser for more strict parsing to a struct in cases where is required.

Alignment with Express API

BodyParser middleware for JSON in express permit you to add different options that affect the parsing

HTTP RFC Standards Compliance

Confirmed

API Stability

DisallowUnknownFields is a native functions of the Decoder from native Go package json

Feature Examples

type Cat struct {
     Name
}


POST /cats
{
  “Name”: “lasagna”
   “Age”: 3
}

Response:
Error the request body not match exactly the struct of Cat
p := new(Person)
if err := c.BodyParser(p,Options{DisallowUnknownFields:true}); err != nil {
   return err
}

Checklist:

  • I agree to follow Fiber's Code of Conduct.
  • I have searched for existing issues that describe my proposal before opening this one.
  • I understand that a proposal that does not meet these guidelines may be closed without explanation.
Copy link

welcome bot commented Feb 13, 2024

Thanks for opening your first issue here! 🎉 Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord

@ReneWerner87
Copy link
Member

we want to fundamentally adapt the parsing of the body information, if necessary we can take this into account in the pull request

#2006

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants