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

Unexpected behavior with "use_raw_data" #6

Open
weierophinney opened this issue Dec 31, 2019 · 0 comments
Open

Unexpected behavior with "use_raw_data" #6

weierophinney opened this issue Dec 31, 2019 · 0 comments

Comments

@weierophinney
Copy link
Contributor

If I set my controller's option for use_raw_data to false, I'd expect that instead of getting everything that's passed in (unfiltered expected fields as well as all the other stuff someone may be passing in) I would only get the filtered, expected fields. Previously it was common to grab just the filtered and expected values in the resource with something like

$data = $this->getInputFilter()->getValues()

However, it appears that if use_raw_data is false, you'll get the filtered expected values plus any other unfiltered, unexpected values as well which seems to be less than ideal.

Previously it was possible to ignore any incoming parameters that you didn't care about and the API would work. There is another new setting "allows_only_fields_in_filter" which if set to true means that it will actually send back a 422 validation error response for the fields that are not defined in your input filter.

It seems it would make sense to allow the resource method to receive only the valid, filtered values that were expected and throw away the rest. Right now the only way to do that is to grab the input filter from within the method and call getInputFilter()->getValues() or something similar.

I'd appreciate any thoughts or comments on it. Perhaps I'm just doing it wrong. It does seem that it'd be simpler to test if I knew I could just pass in and test with validated and filtered values and not need to worry about the input filter dependency within the method.

Thank you.


Originally posted by @dstockto at zfcampus/zf-content-validation#59

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

No branches or pull requests

1 participant