java-json-tools / json-schema-validator

A JSON Schema validation implementation in pure Java, which aims for correctness and performance, in that order
http://json-schema-validator.herokuapp.com/
Other
1.63k stars 399 forks source link

Set default value after validating #266

Open DatPhanTien opened 6 years ago

DatPhanTien commented 6 years ago

Dear,

I would like to know that whether it is possible to apply the default values defined in the schema once the validation is done. For instance if I define a filed with a default value in my schema. In the JSON file, this field might not be mentioned, so it is supposed to take the default value. If one has to fetch the default values manually, it is not going to be efficient.

As the validation process has to pass by each field at least once, could we add an option to set the default value if the field is not mention?

Best regards Tien Dat

abersnaze commented 5 years ago

Some way to get at the annotations has grown to be pretty important for our application and being strictly about validation means we'll likely have to switch to or build a different library.

https://json-schema.org/understanding-json-schema/reference/generic.html#annotations