15#include <nlohmann/json.hpp>
19#include "StringMap.hpp"
48 using SchemaDataPtr = std::unique_ptr<SchemaData>;
102 nlohmann::json
schema(std::string_view
id)
const;
120 nlohmann::json::json_pointer basePath = nlohmann::json::json_pointer{})
const;
Convenience macros to explicitly control copy and move semantics.
DISABLE_COPY(JsonValidator)
Copying is disabled.
nlohmann::json schema(std::string_view id) const
Retrieve the JSON Schema associated with an id.
static ValidationResult validateOnceWithSchema(nlohmann::json schema, nlohmann::json const &json)
Validate a JSON document against a schema without registering it.
std::vector< std::string > allSchemaIds() const
List all registered schema identifiers.
JsonValidator & operator=(JsonValidator &&other)
Move-assign a validator.
bool isRegistered(std::string_view id) const noexcept
Check whether a schema is registered.
void registerSchema(std::string_view id, nlohmann::json schema, bool allowOverride=false)
Register a JSON Schema under an identifier.
ValidationResult validate(std::string_view id, nlohmann::json const &json, nlohmann::json::json_pointer basePath=nlohmann::json::json_pointer{}) const
Validate a JSON document against a registered schema.
JsonValidator(JsonValidator &&other)
Move-construct a validator.
void deregisterSchema(std::string_view id)
Deregister a schema.
~JsonValidator()
Destroy the validator and release all registered schemas.
JsonValidator()
Construct an empty validator.
Definition SystemConfigCommandHandler.hpp:15
std::unordered_map< std::string, T, TransparentHash, TransparentEqual, Allocator > UnorderedStringMap
Convenience alias for an unordered map keyed by std::string with transparent lookup.
Definition StringMap.hpp:76
Result returned by validation functions.
Definition JsonValidator.hpp:53
bool valid
Whether validation succeeded.
Definition JsonValidator.hpp:55
std::vector< std::string > errors
List of validation error messages (empty when valid is true).
Definition JsonValidator.hpp:57