SchemaInspector.sanitize()

Sanitize some json data against a schema.

Schema-Inspector is a powerful tool to sanitize and validate JS objects. It's designed to work both client-side and server-side and to be scalable with allowing asynchronous and synchronous calls.

Usage

Hover over inputs/exits for more info.

var SchemaInspector = require('machinepack-schemainspector');


// Sanitize some json data against a schema.

SchemaInspector.sanitize({

schema: {},

data: '*',

}).exec({

// An unexpected error occurred.

error: function (err) {

 

},

// OK.

success: function () {

 

},

});

Inputs

schema required

The JSON-schema to sanitize against

{}
data required

The data to sanitize (i.e. the "JSON instance")

'*'

Exits

error

An unexpected error occurred.

success

OK.

(varies based on provided inputs)