JSONDValidator

JSONDValidator

new JSONDValidator()

The main validator class

Source:

Methods

addSchema(schemaID, schema)

Adds a schema definition for references lookup

Source:
Parameters:
Name Type Description
schemaID String

Schema identifier

schema Mixed

An arbitrary JSOND text

Example
var validator = new JSONDValidator();
validator.addSchema('http://foo.com/id.json', 'integer')
// With lazy mode, schema compilation is done on the first use
validator.addSchema('http://foo.com/id.json', 'integer', true)

getDereferencedSchema(schemaID) → {Object}

Returns the dereferenced schema for the given ID. The dereferenced schema contains the resolved references based on the interal schema map.

Source:
Parameters:
Name Type Description
schemaID String

A JSOND schema identifier

Returns:
Type:
Object

validate(data, schemaID) → {Object}

Validates a given data object based on a schema definition or identifier. Returns an object with the following properties:

  • valid - boolean result of the validation
  • errors - list of errors detected at validation
Source:
Parameters:
Name Type Description
data Mixed

An arbitrary data object

schemaID String

Schema identifier

Returns:
Type:
Object

{ valid: Boolean, errors: Array }

Example
var validator = new JSONDValidator();
validator.addSchema('http://foo.com/id.json', 'integer');
var result = validator.validate(id, 'http://foo.com/id.json');

Generated by JSDoc 3.5.5 on Fri Nov 03 2017 17:51:38 GMT+0000 (UTC) using the Minami theme.