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

unmarshal: add strict mode #372

Closed
wants to merge 1 commit into from
Closed

Conversation

oncilla
Copy link
Contributor

@oncilla oncilla commented Apr 25, 2020

This PR adds strict mode to the Decoder. It can be enabled with the
Strict method.

In the strict mode, the decoder fails if any fields that were part
of the input do not have a corresponding field in the struct.

The decoder only modifies the visitor state in case strict mode is enabled.
Thus, not forcing unnecessary allocations, when not needed.

This PR adds a strict mode to the Decoder. It can be enabled with the
`Strict` method.

In the strict mode, the decoder fails if any fields that were part
of the input do not have a corresponding field in the struct.
@codecov
Copy link

codecov bot commented Apr 25, 2020

Codecov Report

Merging #372 into master will increase coverage by 0.07%.
The diff coverage is 98.11%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #372      +/-   ##
==========================================
+ Coverage   95.08%   95.16%   +0.07%     
==========================================
  Files          10       10              
  Lines        2118     2170      +52     
==========================================
+ Hits         2014     2065      +51     
- Misses         64       65       +1     
  Partials       40       40              
Impacted Files Coverage Δ
marshal.go 94.64% <98.11%> (+0.33%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 947ab3f...d522942. Read the comment docs.

pelletier pushed a commit that referenced this pull request Apr 28, 2020
This PR adds a strict mode to the Decoder. It can be enabled with the
`Strict` method.

In the strict mode, the decoder fails if any fields that were part
of the input do not have a corresponding field in the struct.

Fixes #277
@pelletier
Copy link
Owner

Merged in d3c92c5 (just added a test case for successful parse in strict mode). Thank you!

@pelletier pelletier closed this Apr 28, 2020
@oncilla
Copy link
Contributor Author

oncilla commented Apr 28, 2020

awesome thanks 👍

@oncilla oncilla deleted the strict-mode branch April 28, 2020 18:23
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

Successfully merging this pull request may close these issues.

2 participants