jayschema icon indicating copy to clipboard operation
jayschema copied to clipboard

Add method to sanitize input

Open bachp opened this issue 12 years ago • 1 comments

The sanitize method should take a schema and an input json. It should then output a version of the input that corresponds to the schema or throw an error if not possible.

For example it should:

  1. Remove fields that are present but not defined in the schema
  2. Keep fields that are correct according to the schema
  3. Remove fields that don't match the schema but are optional
  4. Throw an error if a required field is missing

Optionally it would also be good to have a strict mode so that in case 2) an error would be thrown as well.

bachp avatar Jan 18 '14 19:01 bachp

+1, this would be perfect for what I'd like to do!

orospakr avatar Aug 02 '14 14:08 orospakr