|
nfx-serialization 0.3.0
Cross-platform C++ JSON serialization library with extensible trait capabilities
|
JSON Schema validator for Document instances. More...
#include <nfx/serialization/json/SchemaValidator.h>
Classes | |
| struct | Options |
| Configuration options for validation. More... | |
Public Member Functions | |
| SchemaValidator () | |
| Default constructor - creates empty validator. | |
| SchemaValidator (const Document &schema) | |
| Construct validator with schema (default options). | |
| SchemaValidator (const Document &schema, const Options &options) | |
| Construct validator with schema. | |
| SchemaValidator (const SchemaValidator &other) | |
| Copy constructor. | |
| SchemaValidator (SchemaValidator &&other) noexcept | |
| Move constructor. | |
| ~SchemaValidator () | |
| Destructor. | |
| SchemaValidator & | operator= (const SchemaValidator &other) |
| Copy assignment operator. | |
| SchemaValidator & | operator= (SchemaValidator &&other) noexcept |
| Move assignment operator. | |
| bool | load (const Document &schema) |
| Load JSON schema from Document. | |
| bool | load (std::string_view schemaJson) |
| Load JSON schema from string. | |
| bool | hasSchema () const |
| Check if validator has valid schema loaded. | |
| void | clear () |
| Clear loaded schema. | |
| Document | schema () const |
| Get current schema as Document. | |
| ValidationResult | validate (const Document &document) const |
| Validate Document against loaded schema. | |
| ValidationResult | validateAtPath (const Document &document, std::string_view documentPath="", std::string_view schemaPath="") const |
| Validate Document at specific path against schema. | |
| std::string | version () const |
| Get schema version/draft URI. | |
| SchemaDraft | draft () const |
| Get detected JSON Schema draft version. | |
| std::string | draftString () const |
| Get schema draft version as human-readable string. | |
| std::string | title () const |
| Get schema title. | |
| std::string | description () const |
| Get schema description. | |
| const Options & | options () const noexcept |
| Get validation options. | |
JSON Schema validator for Document instances.
Provides comprehensive JSON Schema Draft 2020-12 validation capabilities including type checking, constraint validation, object/array validation, and custom validation rules. Supports schema loading from Documents and detailed error reporting with path tracking.
Definition at line 295 of file SchemaValidator.h.
| nfx::serialization::json::SchemaValidator::SchemaValidator | ( | ) |
Default constructor - creates empty validator.
Creates validator without schema. Must load schema before validation.

|
explicit |
Construct validator with schema (default options).
| schema | JSON Schema document to use for validation |

| nfx::serialization::json::SchemaValidator::SchemaValidator | ( | const Document & | schema, |
| const Options & | options ) |
Construct validator with schema.
| schema | JSON Schema document to use for validation |
| options | Validation options |

| nfx::serialization::json::SchemaValidator::SchemaValidator | ( | const SchemaValidator & | other | ) |
Copy constructor.
| other | The validator to copy from |

|
noexcept |
Move constructor.
| other | The validator to move from |

| std::string nfx::serialization::json::SchemaValidator::description | ( | ) | const |
Get schema description.
| SchemaDraft nfx::serialization::json::SchemaValidator::draft | ( | ) | const |
Get detected JSON Schema draft version.
| std::string nfx::serialization::json::SchemaValidator::draftString | ( | ) | const |
Get schema draft version as human-readable string.
| bool nfx::serialization::json::SchemaValidator::hasSchema | ( | ) | const |
Check if validator has valid schema loaded.
| bool nfx::serialization::json::SchemaValidator::load | ( | const Document & | schema | ) |
Load JSON schema from Document.
| schema | JSON Schema document |

| bool nfx::serialization::json::SchemaValidator::load | ( | std::string_view | schemaJson | ) |
Load JSON schema from string.
| schemaJson | JSON Schema as string |
| SchemaValidator & nfx::serialization::json::SchemaValidator::operator= | ( | const SchemaValidator & | other | ) |
Copy assignment operator.
| other | The validator to copy from |

|
noexcept |
Move assignment operator.
| other | The validator to move from |

|
noexcept |
Get validation options.

| Document nfx::serialization::json::SchemaValidator::schema | ( | ) | const |
Get current schema as Document.

| std::string nfx::serialization::json::SchemaValidator::title | ( | ) | const |
Get schema title.
| ValidationResult nfx::serialization::json::SchemaValidator::validate | ( | const Document & | document | ) | const |
Validate Document against loaded schema.
| document | The JSON document to validate |
| std::runtime_error | if no schema is loaded |
| ValidationResult nfx::serialization::json::SchemaValidator::validateAtPath | ( | const Document & | document, |
| std::string_view | documentPath = "", | ||
| std::string_view | schemaPath = "" ) const |
Validate Document at specific path against schema.
| document | The JSON document to validate |
| documentPath | Path within document to validate (empty for root) |
| schemaPath | Path within schema to validate against (empty for root schema) |
| std::string nfx::serialization::json::SchemaValidator::version | ( | ) | const |
Get schema version/draft URI.