nfx-serialization 0.3.0
Cross-platform C++ JSON serialization library with extensible trait capabilities
Loading...
Searching...
No Matches
nfx::serialization::json::ValidationError Class Referencefinal

Represents a single JSON schema validation error. More...

#include <nfx/serialization/json/SchemaValidator.h>

Classes

struct  ErrorEntry
 Simple error entry structure for convenient ValidationError construction. More...

Public Member Functions

 ValidationError (const ErrorEntry &entry)
 Construct validation error from ErrorEntry struct.
 ValidationError (std::string path, std::string message, std::string constraint, std::string expectedValue={}, std::string actualValue={})
 Construct validation error.
 ~ValidationError ()=default
 Destructor.
const std::string & path () const noexcept
 Get the JSON path where validation failed.
const std::string & message () const noexcept
 Get human-readable error message.
const std::string & constraint () const noexcept
 Get the constraint type that failed.
const std::string & expectedValue () const noexcept
 Get expected value or constraint.
const std::string & actualValue () const noexcept
 Get actual value found in document.
std::string toString () const
 Get formatted error string.

Detailed Description

Represents a single JSON schema validation error.

Contains detailed information about validation failures including the failed constraint, document path, expected vs actual values, and human-readable error messages.

Definition at line 54 of file SchemaValidator.h.

Constructor & Destructor Documentation

◆ ValidationError() [1/2]

nfx::serialization::json::ValidationError::ValidationError ( const ErrorEntry & entry)
explicit

Construct validation error from ErrorEntry struct.

Parameters
entryError entry with all validation details

◆ ValidationError() [2/2]

nfx::serialization::json::ValidationError::ValidationError ( std::string path,
std::string message,
std::string constraint,
std::string expectedValue = {},
std::string actualValue = {} )

Construct validation error.

Parameters
pathJSON path where validation failed
messageHuman-readable error description
constraintThe schema constraint that failed (e.g., "type", "minLength")
expectedValueExpected value or constraint (optional)
actualValueActual value found in document (optional)
Here is the call graph for this function:

Member Function Documentation

◆ actualValue()

const std::string & nfx::serialization::json::ValidationError::actualValue ( ) const
inlinenoexcept

Get actual value found in document.

Returns
Actual value string, or empty if not applicable

Definition at line 137 of file SchemaValidator.h.

◆ constraint()

const std::string & nfx::serialization::json::ValidationError::constraint ( ) const
inlinenoexcept

Get the constraint type that failed.

Returns
Constraint name (e.g., "type", "minLength", "required")

Definition at line 125 of file SchemaValidator.h.

Here is the caller graph for this function:

◆ expectedValue()

const std::string & nfx::serialization::json::ValidationError::expectedValue ( ) const
inlinenoexcept

Get expected value or constraint.

Returns
Expected value string, or empty if not applicable

Definition at line 131 of file SchemaValidator.h.

Here is the caller graph for this function:

◆ message()

const std::string & nfx::serialization::json::ValidationError::message ( ) const
inlinenoexcept

Get human-readable error message.

Returns
Error description

Definition at line 119 of file SchemaValidator.h.

Here is the caller graph for this function:

◆ path()

const std::string & nfx::serialization::json::ValidationError::path ( ) const
inlinenoexcept

Get the JSON path where validation failed.

Returns
Path string (e.g., "/users/0/email")

Definition at line 113 of file SchemaValidator.h.

Here is the caller graph for this function:

◆ toString()

std::string nfx::serialization::json::ValidationError::toString ( ) const

Get formatted error string.

Returns
Complete formatted error message with path and details

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