json-gate
json-gate copied to clipboard
Clear object using new form to additionalProperties
This feature remove all non-matching properties from original JSON object.
How to use:
additionalProperties: 'remove'
See bellow:
// Schema
{
str: { type: 'string' },
additionalProperties: 'remove'
}
// Object
{
str: 'hi',
extra: 'unimportant data, discard this',
extra1: 'discard this'
}
// Result object (after validate):
{
str: 'hi'
}
// Getting result object
newObject = schema.validate(Object);
// or
schema.validate(Object, function(err, obj) {
newObject = obj;
});
Obs.: I moved to new branch, because I needed merge my features in master.