Support (optional) adding of default values to input data while validating #48
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added a :insert_defaults option that will update the input JSON data with default values from the schema where they are supplied via the "default" property and the "readonly" property is not set. This is to avoid the client reading the data having to interpret the schema just to interpolate unset properties with their defaults.
The default value is inserted before that part of the node is validated so conformance of the default with the schema is checked and affects the overall validation outcome as it should.
I've seen a similar feature in a different parser gem but they only auto-insert the default if the property is required. However I would say that it doesn't make much sense to have a default value and not set required => true.