Constructor
new Schema(loader, def)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
loader |
module:core/schema~SchemaLoader
|
JSON schema loader. |
def |
Object
|
The JSON schema definition. |
Methods
getArrayDefaultValue(def)
Create the module:core/schema~DefaultValue for an array-typed JSON schema.
Each possible type of the array elements defined in oneOf
will be processed and a
module:core/schema~DefaultValue will be added to the result array.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
def |
Object
|
JSON schema definition of the array. |
Returns:
module:core/schema~DefaultValue The module:core/schema~DefaultValue for the
array definition.
getDefaultValue(def)
Create the module:core/schema~DefaultValue for any JSON schema.
- Source:
Parameters:
Name | Type | Default | Description |
---|---|---|---|
def |
Object
|
null | JSON schema definition. |
Returns:
module:core/schema~DefaultValue The module:core/schema~DefaultValue for the
definition.
getObjectDefaultValue(def)
Create the module:core/schema~DefaultValue for an object-typed JSON schema.
The first possible type of the object element defined in oneOf
will be processed and its
module:core/schema~DefaultValue will be merged with the module:core/schema~DefaultValue
created from the properties
definition.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
def |
Object
|
JSON schema definition of the object. |
Returns:
module:core/schema~DefaultValue The module:core/schema~DefaultValue for the
object definition.
getReferredDefaultValue(def)
Create the module:core/schema~DefaultValue for any JSON schema that is purely defined by its
$ref
.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
def |
Object
|
JSON schema definition. |
Returns:
module:core/schema~DefaultValue The module:core/schema~DefaultValue for the
definition.
getTypedDefaultValue(def)
Create the module:core/schema~DefaultValue for any typed JSON schema that is not purely defined
by its
$ref
.
If the definition also contains a $ref
, the module:core/schema~DefaultValue for the
$ref
definition will be merged to the module:core/schema~DefaultValue of the current
definition.
If type
of the JSON schema is of primitive types, and the nullable
is set to
false
in the schema definition, primitive default values will be set insided the result
module:core/schema~DefaultValue.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
def |
Object
|
JSON schema definition. |
Throws:
-
If
type
is undefined or it is 'array', 'object', or primitive types. - Type
-
Error
Returns:
module:core/schema~DefaultValue The module:core/schema~DefaultValue for the
definition.
validate(obj) → {boolean|Object}
Validate an object against the JSON schema.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
obj |
any
|
Object to be validated. |
Returns:
- Type:
-
boolean
|Object
True if Object is valid, or validation errors.