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

Support (optional) adding of default values to input data while validating #48

Merged
merged 2 commits into from
Dec 14, 2012
Merged

Conversation

goodsimon
Copy link
Contributor

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.

Update docs to include :insert_defaults option example
@hoxworth hoxworth merged commit 2c61417 into voxpupuli:master Dec 14, 2012
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