new Validator()
Validator a Javascript against a JSON Schema thanks to tv4 module.
- Source:
- See:
Methods
addSchema(obj, pathopt) → {Object}
Add a Schema definition for a specific object.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
obj |
Object | Object to attache to definition on |
|
path |
String |
<optional> |
Path to the JSON Schema definition |
- Source:
Returns:
- JSON Schema definition
- Type
- Object
getClassName(obj) → {String}
Get the className from an object.
Parameters:
Name | Type | Description |
---|---|---|
obj |
String | Object | Object or string |
- Source:
Returns:
- Name of the constructor
- Type
- String
getSchema(obj) → {Object}
Get the JSON Schema definition from the object given as input parameter.
Parameters:
Name | Type | Description |
---|---|---|
obj |
Object | Object to search a JSON Schema for |
- Source:
Returns:
- JSON Schema definition
- Type
- Object
isValid(obj) → {Boolean}
Check if the object is valid against its JSON Schema definition.
Parameters:
Name | Type | Description |
---|---|---|
obj |
Object | Object with toJSON() implemented |
- Source:
Returns:
- True if valid, False otherwise
- Type
- Boolean