Methods
addSchema(schemaID, schema)
Adds a schema definition for references lookup
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.
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 validationerrors
- list of errors detected at validation
Parameters:
Name | Type | Description |
---|---|---|
data |
Mixed
|
An arbitrary data object |
schemaID |
String
|
Schema identifier |
Returns:
- Type:
-
Object
{ valid: Boolean, errors: Array