new Schema()
Methods
-
async, static init() → {Promise}
-
Initialize the schema system
Returns:
Promise -A Promise that resolves when initialization is complete.
-
static loadSchema(name, str)
-
Loads a new JSON schema for future reference. Since JSON schemes can cross-reference each other through $id and $ref, all relevant schemas must be loaded so that references resolve before attempting to validate data.
Parameters:
Name Type Description name
string The human-readable name of the schema for future reference in the
validate
method.str
string The name of a file to load or a string representing a JSON schema
-
async, static shutdown() → {Promise}
-
Shutdown the schema system
Returns:
Promise -A Promise that resolves when shutdown is complete.
-
static validate(name, data) → {boolean}
-
Validates data based on the name of the schema.
Parameters:
Name Type Description name
string Then name (specified during
loadSchema
) or JSON Schema $id of the schema to use for validation.data
any The data to validate
Returns:
boolean -true
if data is valid for the specified schema,false
otherwise.