MySQL 8.3.0
Source Code Documentation
Json_schema_validator Class Reference

Json_schema_validator is an object that contains a JSON Schema that can be re-used multiple times. More...

#include <json_schema.h>

Classes

class  My_remote_schema_document_provider
 This object acts as a handler/callback for the JSON schema validator and is called whenever a schema reference is encountered in the JSON document. More...
 

Public Member Functions

 Json_schema_validator (const rapidjson::Document &schema_document)
 Construct the cached JSON Schema with the provided JSON document. More...
 
bool is_valid_json_schema (const char *document_str, size_t document_length, const char *function_name, bool *is_valid, Json_schema_validation_report *report) const
 Validate a JSON input against the cached JSON Schema. More...
 

Private Attributes

My_remote_schema_document_provider m_remote_document_provider
 
rapidjson::SchemaDocument m_cached_schema
 

Detailed Description

Json_schema_validator is an object that contains a JSON Schema that can be re-used multiple times.

This is useful in the cases where we have a JSON Schema that doesn't change (which should be quite often).

Constructor & Destructor Documentation

◆ Json_schema_validator()

Json_schema_validator::Json_schema_validator ( const rapidjson::Document &  schema_document)

Construct the cached JSON Schema with the provided JSON document.

Parameters
schema_documentA JSON document that contains the JSON Schema definition

Member Function Documentation

◆ is_valid_json_schema()

bool Json_schema_validator::is_valid_json_schema ( const char *  document_str,
size_t  document_length,
const char *  function_name,
bool *  is_valid,
Json_schema_validation_report report 
) const

Validate a JSON input against the cached JSON Schema.

Parameters
document_strA pointer to the JSON input
document_lengthThe length of the JSON input
function_nameThe function name of the caller (to be used in error reporting)
[out]is_validThe result of the validation
[out]reportA structure containing a detailed report from the validation. Is only populated if is_valid is set to "false" Can be nullptr if a detailed report isn't needed.
Return values
trueon error (my_error has been called)
falseon success (validation result can be found in the output parameter is_valid)

Member Data Documentation

◆ m_cached_schema

rapidjson::SchemaDocument Json_schema_validator::m_cached_schema
private

◆ m_remote_document_provider

My_remote_schema_document_provider Json_schema_validator::m_remote_document_provider
private

The documentation for this class was generated from the following files: