Constructor
(async) new Schema(schemaopt, refsopt, asyncopt)
Properties:
Name | Type | Default | Description |
---|---|---|---|
errors |
Array.<string>
|
A copy of the List of error strings from the last time validate ran. |
|
isAsync |
Boolean
|
false | A copy of the async validation setting. |
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
schema |
Object
|
<optional> |
Optional JSON Schema definition. | |
refs |
Object
|
<optional> |
Optional hash of cached JSON Schemas that are referenced in the main schema. | |
async |
Boolean
|
<optional> |
false | Optional boolean flag to enable asynchronous validations. |
Methods
(async) assign(schema, refsopt) → {Schema}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
schema |
Object
|
The supplied JSON Schema definition. | |
refs |
Object
|
<optional> |
Optionally supplied cached references of other JSON Schema definitions. |
(async) validate(data, schemaopt) → {Boolean}
synchronous
or asynchronous
using a wrapping function during construction. It defaults to synchronous
for better performance.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
data |
The data to validate against the JSON Schema definition instance. | |||
schema |
Schema
|
<optional> |
this | Optionally pass nested JSON Schema definitions of the instance for partial schema validation or other instances of the JSON Schema class. |
Returns:
- Type:
-
Boolean
true
if validation is successful, otherwise false
.