MySQL 9.1.0
Source Code Documentation
Json_schema_validator_impl Class Reference

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

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_impl (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 JsonSchemaErrorHandler &error_handler, const JsonErrorHandler &depth_handler, 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_impl 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_impl()

Json_schema_validator_impl::Json_schema_validator_impl ( 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_impl::is_valid_json_schema ( const char *  document_str,
size_t  document_length,
const JsonSchemaErrorHandler error_handler,
const JsonErrorHandler depth_handler,
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
error_handlerError handlers to be called when parsing errors occur.
depth_handlerPointer to a function that should handle error occurred when depth is exceeded.
[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_impl::m_cached_schema
private

◆ m_remote_document_provider

My_remote_schema_document_provider Json_schema_validator_impl::m_remote_document_provider
private

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