Constructor
(async) new Model(data, schema, refsopt, descriptorsopt)
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
data |
Object
|
A FSA Object literal containing the Model's type and optional meta and payload .
|
||
schema |
Object
|
Schema
|
An Object literal or Schema instance containing the JSON Schema definition of the Model. | ||
refs |
Object
|
<optional> |
An optional Object literal of cached JSON Schema definitions referenced in the main schema. | |
descriptors |
Object
|
<optional> |
{ configurable: true, enumerable: true, writable: true } | An optional Object literal containing the desired property descriptors for the Model instance. |
Methods
(static) errors(model) → {Array.<string>}
Static method to get the List of errors from the last time
validate
was called on the associated JSON Schema instance from the Model instance.
Parameters:
Name | Type | Description |
---|---|---|
model |
Model
|
The Model instance. |
Returns:
- Type:
-
Array.<string>
The List of errors.
(static) schema(model) → {Schema}
Static method to get the JSON Schema instance associated with the instance of a Model.
Parameters:
Name | Type | Description |
---|---|---|
model |
Model
|
The Model instance. |
(static) validate(model, schemaopt) → {Boolean}
Static method to manually run the JSON Schema instance's
validate
method on the specified Model instance. This method will also perform partial schema validation if passed as the second parameter.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
model |
Model
|
The Model instance. | |
schema |
Schema
|
<optional> |
An optional JSON Schema instance. |
Returns:
- Type:
-
Boolean
true
if validation is successful, otherwise false
.
(static) version(model, versionopt) → {Number|undefined}
Static method to get the version associated with the instance of a Model.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
model |
Model
|
The Model instance. | |
version |
Number
|
<optional> |
An optional version Number to set |
Returns:
- Type:
-
Number
|undefined
- The version of the Model instance.
toJSON() → {Object}
Method used to transform the Model instance to conform to the FSA specification standard action definition.
Returns:
- Type:
-
Object
An Object literal containing the
meta
and optional data
of the Model instance.