pjson 2.0.0
A small, owning JSON value for C++11
Loading...
Searching...
No Matches
ByteDance::pJsonSchemaValidator::Options Struct Reference

Bounds schema work and controls dialect, format, and resolver policy. More...

#include <pjson_schema.h>

Static Public Member Functions

static Options trustedRegex ()
 Disables only regex restrictions; all other defaults remain enabled.
 
static Options strict ()
 Returns the defaults with strict fail-closed subset mode enabled.
 
static Options modernSubset ()
 Selects modern subset semantics: $ref siblings apply and format is annotation-only unless the caller re-enables it.
 
static Options draft2020 ()
 Selects the official Draft 2020-12 dialect, modern $ref semantics, annotation-only format, and custom dialect resolution.
 

Public Attributes

size_t maxRegexPatternBytes
 0 = unlimited (default: 256).
 
size_t maxRegexSubjectBytes
 0 = unlimited (default: 4096).
 
bool allowUnsafeRegex
 Permits unrestricted ECMAScript regex (default false). Recursive validation depth (default and absolute hard ceiling: 32). Zero selects 32, and larger values are clamped to 32.
 
size_t maxValidationDepth
 Recursive validation depth budget. Resolved references (default 1024); zero selects the hard ceiling of 1024.
 
size_t maxRefResolutions
 Resolved-reference budget. Validation work units (default 1,000,000); zero selects that hard ceiling.
 
size_t maxValidationWork
 Total validation work-unit budget. Reported errors (default 100); zero selects the hard ceiling of 100.
 
size_t maxErrors
 Collected top-level and nested diagnostic budget.
 
bool stopAfterFirstError
 Stops compilation or validation after the first error.
 
bool collectNestedCauses
 Retains bounded anyOf/oneOf branch failures.
 
bool validateFormats
 Validates known string formats (default true).
 
bool strictSubset
 Rejects unsupported standard keywords when true. Applies $ref siblings using pjson's modern subset semantics. The default false preserves legacy Draft 7 replacement semantics.
 
bool refSiblings
 True when $ref siblings must also be evaluated. Allows an unknown absolute $schema URI to be resolved during construction and interpreted through its $vocabulary object.
 
bool resolveCustomDialects
 Enables explicit custom meta-schema resolution. Retrieval URI used as the initial base when the root has no $id. Leave empty only when all references are absolute or local.
 
std::string retrievalUri
 Initial base URI for a root without $id. Dialect used when the root schema has no $schema. An empty value selects documentedSubsetDialectUri(). Use draft2020() instead of setting this field directly when selecting the official dialect.
 
std::string defaultDialectUri
 Dialect used when $schema is absent.
 
Resolver resolver
 Construction-only external-schema resolver.
 
void * resolverContext
 Construction-only opaque resolver context.
 
size_t maxResolvedDocuments
 External-document budget (default 32).
 
size_t maxResolvedBytes
 Compact resolved-DOM byte budget (default 16 MiB). Selects bounded safe-regex, traversal, reference, work, error, and format defaults.
 

Detailed Description

Bounds schema work and controls dialect, format, and resolver policy.

Bounds schema-validation work and controls optional format checks.

By default only a conservative, non-ambiguous ECMAScript subset is accepted and both pattern/subject sizes are capped, preventing catastrophic backtracking. trustedRegex() restores unrestricted ECMAScript regex behavior for trusted schemas/data; the backend still enforces its own finite work ceiling.

Recursive validation depth defaults to an absolute hard ceiling of 32. A zero value selects that ceiling, and larger values are clamped to it so no caller configuration can make recursive keyword evaluation exceed the conservative native-stack bound. Other zero-valued validation budgets retain their documented hard ceilings; only regex byte limits use zero as unlimited. defaultDialectUri defaults to documentedSubsetDialectUri(); an empty value selects the same default. retrievalUri supplies the root's base when $id is absent. resolver is the only way to load an external schema resource; pjson never performs I/O. maxResolvedDocuments and maxResolvedBytes bound resolver amplification. modernSubset() enables modern $ref sibling semantics and the Draft 2020-12 annotation-only format default, while normal options preserve legacy Draft 7-compatible behavior. draft2020() additionally selects the official dialect and meta-schema compilation.

Definition at line 143 of file pjson_schema.h.

Member Function Documentation

◆ draft2020()

static Options ByteDance::pJsonSchemaValidator::Options::draft2020 ( )
static

Selects the official Draft 2020-12 dialect, modern $ref semantics, annotation-only format, and custom dialect resolution.

◆ modernSubset()

static Options ByteDance::pJsonSchemaValidator::Options::modernSubset ( )
static

Selects modern subset semantics: $ref siblings apply and format is annotation-only unless the caller re-enables it.

◆ strict()

static Options ByteDance::pJsonSchemaValidator::Options::strict ( )
static

Returns the defaults with strict fail-closed subset mode enabled.

◆ trustedRegex()

static Options ByteDance::pJsonSchemaValidator::Options::trustedRegex ( )
static

Disables only regex restrictions; all other defaults remain enabled.

Member Data Documentation

◆ allowUnsafeRegex

bool ByteDance::pJsonSchemaValidator::Options::allowUnsafeRegex

Permits unrestricted ECMAScript regex (default false). Recursive validation depth (default and absolute hard ceiling: 32). Zero selects 32, and larger values are clamped to 32.

Definition at line 146 of file pjson_schema.h.

◆ collectNestedCauses

bool ByteDance::pJsonSchemaValidator::Options::collectNestedCauses

Retains bounded anyOf/oneOf branch failures.

Definition at line 157 of file pjson_schema.h.

◆ defaultDialectUri

std::string ByteDance::pJsonSchemaValidator::Options::defaultDialectUri

Dialect used when $schema is absent.

Definition at line 177 of file pjson_schema.h.

◆ maxErrors

size_t ByteDance::pJsonSchemaValidator::Options::maxErrors

Collected top-level and nested diagnostic budget.

Definition at line 155 of file pjson_schema.h.

◆ maxRefResolutions

size_t ByteDance::pJsonSchemaValidator::Options::maxRefResolutions

Resolved-reference budget. Validation work units (default 1,000,000); zero selects that hard ceiling.

Definition at line 151 of file pjson_schema.h.

◆ maxRegexPatternBytes

size_t ByteDance::pJsonSchemaValidator::Options::maxRegexPatternBytes

0 = unlimited (default: 256).

Definition at line 144 of file pjson_schema.h.

◆ maxRegexSubjectBytes

size_t ByteDance::pJsonSchemaValidator::Options::maxRegexSubjectBytes

0 = unlimited (default: 4096).

Definition at line 145 of file pjson_schema.h.

◆ maxResolvedBytes

size_t ByteDance::pJsonSchemaValidator::Options::maxResolvedBytes

Compact resolved-DOM byte budget (default 16 MiB). Selects bounded safe-regex, traversal, reference, work, error, and format defaults.

Definition at line 181 of file pjson_schema.h.

◆ maxResolvedDocuments

size_t ByteDance::pJsonSchemaValidator::Options::maxResolvedDocuments

External-document budget (default 32).

Definition at line 180 of file pjson_schema.h.

◆ maxValidationDepth

size_t ByteDance::pJsonSchemaValidator::Options::maxValidationDepth

Recursive validation depth budget. Resolved references (default 1024); zero selects the hard ceiling of 1024.

Definition at line 149 of file pjson_schema.h.

◆ maxValidationWork

size_t ByteDance::pJsonSchemaValidator::Options::maxValidationWork

Total validation work-unit budget. Reported errors (default 100); zero selects the hard ceiling of 100.

Definition at line 153 of file pjson_schema.h.

◆ refSiblings

bool ByteDance::pJsonSchemaValidator::Options::refSiblings

True when $ref siblings must also be evaluated. Allows an unknown absolute $schema URI to be resolved during construction and interpreted through its $vocabulary object.

Definition at line 167 of file pjson_schema.h.

◆ resolveCustomDialects

bool ByteDance::pJsonSchemaValidator::Options::resolveCustomDialects

Enables explicit custom meta-schema resolution. Retrieval URI used as the initial base when the root has no $id. Leave empty only when all references are absolute or local.

Definition at line 170 of file pjson_schema.h.

◆ resolver

Resolver ByteDance::pJsonSchemaValidator::Options::resolver

Construction-only external-schema resolver.

Definition at line 178 of file pjson_schema.h.

◆ resolverContext

void* ByteDance::pJsonSchemaValidator::Options::resolverContext

Construction-only opaque resolver context.

Definition at line 179 of file pjson_schema.h.

◆ retrievalUri

std::string ByteDance::pJsonSchemaValidator::Options::retrievalUri

Initial base URI for a root without $id. Dialect used when the root schema has no $schema. An empty value selects documentedSubsetDialectUri(). Use draft2020() instead of setting this field directly when selecting the official dialect.

Definition at line 173 of file pjson_schema.h.

◆ stopAfterFirstError

bool ByteDance::pJsonSchemaValidator::Options::stopAfterFirstError

Stops compilation or validation after the first error.

Definition at line 156 of file pjson_schema.h.

◆ strictSubset

bool ByteDance::pJsonSchemaValidator::Options::strictSubset

Rejects unsupported standard keywords when true. Applies $ref siblings using pjson's modern subset semantics. The default false preserves legacy Draft 7 replacement semantics.

Definition at line 164 of file pjson_schema.h.

◆ validateFormats

bool ByteDance::pJsonSchemaValidator::Options::validateFormats

Validates known string formats (default true).

Definition at line 158 of file pjson_schema.h.


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