jayschema
jayschema copied to clipboard
Add method to sanitize input
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:
- Remove fields that are present but not defined in the schema
- Keep fields that are correct according to the schema
- Remove fields that don't match the schema but are optional
- 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.
+1, this would be perfect for what I'd like to do!