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

Response validation modifies payload #1639

Closed
hueniverse opened this issue May 18, 2014 · 2 comments · Fixed by #1641
Closed

Response validation modifies payload #1639

hueniverse opened this issue May 18, 2014 · 2 comments · Fixed by #1641
Assignees
Labels
breaking changes Change that can breaking existing code bug Bug or defect
Milestone

Comments

@hueniverse
Copy link
Contributor

Unlike input validation, responses should not be modified to comply with validation rules (e.g. casting a string to a number).

@worklez
Copy link

worklez commented Jun 15, 2014

Would it be a valid use case to allow response objects to be stripped by validator? Consider following scenario:

  1. Server is configured with validation: { stripUnknown: true }
  2. Route config has its response: { schema: Joi... } specified
  3. Request handler retrieves a doc which has more keys than needed for the response, but otherwise its satisfies the schema; and calls reply(doc).

As of now, validation would succeed but the response would contain full set of keys, including those not matched by the validator.

This commit Qey@0bb2152 enables response modifications but they're not restricted to stripping.

@hueniverse
Copy link
Contributor Author

Open a new issue requesting this feature. I'll consider it.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
breaking changes Change that can breaking existing code bug Bug or defect
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants