JSONValidator

Class finesse.utilities.JsonValidator

Utility methods for the validation of JSON data against a user-provided schema.

Methods

validateJson(jsonData, schema)

Validates the JSON data by applying a specific schema.

Parameters

Name

Type

Description

Required

jsonData

jsonData

The JSON data to be validated.

Yes

schema

schema

The JSON schema that validates the parameter jsonData. Follow the JSON schema definition standards.

For more information, see http://json-schema.org/.

Yes

Returns

{String} The JSON data in the following format:

Code Snippet
Copy {
    "valid": [true / false],
    "error": [tv4 error object
        if schema is not valid
    ]
}
The error object is as follows:
Code Snippet
Copy{
    "code": 0,
    "message": "Invalid type: string",
    "dataPath": "/intKey",
    "schemaPath": "/properties/intKey/type"
}