json-gate icon indicating copy to clipboard operation
json-gate copied to clipboard

Clear object using new form to additionalProperties

Open andersonba opened this issue 10 years ago • 0 comments

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.

andersonba avatar Mar 28 '14 20:03 andersonba