hoxworth/json-schema — pull request #48 by goodsimon (2012-10-26 17:45:35+00:00)
Title: Support (optional) adding of default values to input data while validating

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.