A high-performance JSON Schema evaluator. More...
Classes | |
| struct | sourcemeta::blaze::Template |
| class | sourcemeta::blaze::Evaluator |
| class | sourcemeta::blaze::EvaluationError |
| struct | sourcemeta::blaze::InstructionExtra |
| struct | sourcemeta::blaze::Instruction |
| struct | sourcemeta::blaze::ValueNone |
| Represents a compiler step empty value. More... | |
| struct | sourcemeta::blaze::ValueRegex |
Enumerations | |
| enum class | sourcemeta::blaze::Mode : std::uint8_t { Mode::FastValidation , Mode::Exhaustive } |
| enum class | sourcemeta::blaze::EvaluationType : std::uint8_t { Pre , Post } |
| enum class | InstructionIndex : std::uint8_t { AssertionFail = 0 , AssertionDefines , AssertionDefinesStrict , AssertionDefinesAll , AssertionDefinesAllStrict , AssertionDefinesExactly , AssertionDefinesExactlyStrict , AssertionDefinesExactlyStrictHash3 , AssertionPropertyDependencies , AssertionType , AssertionTypeAny , AssertionTypeStrict , AssertionTypeStrictAny , AssertionNotTypeStrictAny , AssertionTypeStringBounded , AssertionTypeStringUpper , AssertionTypeArrayBounded , AssertionTypeArrayUpper , AssertionTypeObjectBounded , AssertionTypeObjectUpper , AssertionRegex , AssertionStringSizeLess , AssertionStringSizeGreater , AssertionArraySizeLess , AssertionArraySizeGreater , AssertionObjectSizeLess , AssertionObjectSizeGreater , AssertionEqual , AssertionEqualsAny , AssertionEqualsAnyStringHash , AssertionGreaterEqual , AssertionLessEqual , AssertionGreater , AssertionLess , AssertionUnique , AssertionDivisible , AssertionTypeIntegerBounded , AssertionTypeIntegerBoundedStrict , AssertionTypeIntegerLowerBound , AssertionTypeIntegerLowerBoundStrict , AssertionNumberIntegerBounded , AssertionNumberType , AssertionStringType , AssertionPropertyType , AssertionPropertyTypeEvaluate , AssertionPropertyTypeStrict , AssertionPropertyTypeStrictEvaluate , AssertionPropertyTypeStrictAny , AssertionPropertyTypeStrictAnyEvaluate , AssertionPropertyEqual , AssertionArrayPrefix , AssertionArrayPrefixEvaluate , AssertionObjectPropertiesSimple , AnnotationEmit , AnnotationEmitWrapped , AnnotationToParent , AnnotationBasenameToParent , Evaluate , LogicalNot , LogicalNotEvaluate , LogicalOr , LogicalAnd , LogicalXor , LogicalCondition , LogicalWhenType , LogicalWhenDefines , LogicalWhenArraySizeGreater , LoopPropertiesUnevaluated , LoopPropertiesUnevaluatedExcept , LoopPropertiesMatch , LoopPropertiesMatchClosed , LoopProperties , LoopPropertiesEvaluate , LoopPropertiesRegex , LoopPropertiesRegexClosed , LoopPropertiesStartsWith , LoopPropertiesExcept , LoopPropertiesType , LoopPropertiesTypeEvaluate , LoopPropertiesExactlyTypeStrict , LoopPropertiesExactlyTypeStrictHash , LoopPropertiesTypeStrict , LoopPropertiesTypeStrictEvaluate , LoopPropertiesTypeStrictAny , LoopPropertiesTypeStrictAnyEvaluate , LoopKeys , LoopItems , LoopItemsFrom , LoopItemsUnevaluated , LoopItemsType , LoopItemsTypeStrict , LoopItemsTypeStrictAny , LoopItemsPropertiesExactlyTypeStrictHash , LoopItemsPropertiesExactlyTypeStrictHash3 , LoopItemsIntegerBounded , LoopItemsIntegerBoundedSized , LoopItemsArrayBoundedTypeStrictAny , LoopContains , ControlGroup , ControlGroupWhenDefines , ControlGroupWhenDefinesDirect , ControlGroupWhenType , ControlEvaluate , ControlDynamicAnchorJump , ControlJump } |
| enum class | sourcemeta::blaze::ValueStringType : std::uint8_t { URI , URIReference , URITemplate , IRI , IRIReference , Email , IDNEmail , IPv4 , IPv6 , Hostname , IDNHostname , DateTime , Date , Time , PartialTime , Duration , JSONPointer , RelativeJSONPointer , UUID , Regex , Color , Base64 } |
| enum class | sourcemeta::blaze::ValueNumberType : std::uint8_t { Float , Double } |
Functions | |
| auto | sourcemeta::blaze::from_json (const sourcemeta::core::JSON &json) -> std::optional< Template > |
| auto | sourcemeta::blaze::is_annotation (const InstructionIndex type) noexcept -> bool |
| auto | sourcemeta::blaze::is_wrapped_annotation (const InstructionIndex type) noexcept -> bool |
| auto | sourcemeta::blaze::describe (const Template &schema_template, const bool valid, const Instruction &step, const sourcemeta::core::WeakPointer &evaluate_path, const sourcemeta::core::WeakPointer &instance_location, const sourcemeta::core::JSON &instance, const sourcemeta::core::JSON &annotation) -> std::string |
Variables | |
| constexpr std::size_t | sourcemeta::blaze::JSON_VERSION {15} |
| constexpr std::string_view | sourcemeta::blaze::INSTRUCTION_NAMES [] |
A high-performance JSON Schema evaluator.
This functionality is included as follows:
| struct sourcemeta::blaze::Template |
Represents a compiled schema ready for execution
Public Attributes | |
| bool | dynamic |
| bool | track |
| std::vector< Instructions > | targets |
| std::vector< std::pair< std::size_t, std::size_t > > | labels |
| std::vector< InstructionExtra > | extra |
| std::vector< std::string > | vocabularies |
| The vocabulary URIs that instructions refer to, without duplicates. | |
| std::vector< std::string > | messages |
| The message templates that instructions refer to, without duplicates. | |
| class sourcemeta::blaze::Evaluator |
Public Member Functions | |
| auto | validate (const Template &schema, const sourcemeta::core::JSON &instance) -> bool |
| auto | validate (const Template &schema, const sourcemeta::core::JSON &instance, const Callback &callback) -> bool |
|
inline |
This function evaluates a schema compiler template, returning a boolean without error information. For example:
|
inline |
This method evaluates a schema compiler template, executing the given callback at every step of the way. For example:
| class sourcemeta::blaze::EvaluationError |
An error that represents a schema evaluation error event
| struct sourcemeta::blaze::InstructionExtra |
Satellite data for an instruction that is not needed during fast evaluation
Public Attributes | |
| sourcemeta::core::Pointer | relative_schema_location |
| std::string | keyword_location |
| std::size_t | schema_resource |
| std::size_t | vocabulary |
| std::size_t | message |
| std::size_t | message_detail |
| std::size_t sourcemeta::blaze::InstructionExtra::message |
A one-based index into Template::messages, where zero means the instruction has no message template of its own
| std::size_t sourcemeta::blaze::InstructionExtra::message_detail |
The template to render instead when the instruction has something of its own to report, such as which properties were missing. Zero when the instruction says the same thing either way
| struct sourcemeta::blaze::Instruction |
Represents a single instruction to be evaluated
Public Attributes | |
| InstructionIndex | type |
| sourcemeta::core::Pointer | relative_instance_location |
| Value | value |
| Instructions | children |
| std::size_t | extra_index |
| struct sourcemeta::blaze::ValueNone |
Represents a compiler step empty value.
Public Member Functions | |
| auto | to_json () const -> sourcemeta::core::JSON |
Static Public Member Functions | |
| static auto | from_json (const sourcemeta::core::JSON &) -> std::optional< ValueNone > |
| struct sourcemeta::blaze::ValueRegex |
Represents a compiler step ECMA regular expression value. We store both the original string and the regular expression as standard regular expressions do not keep a copy of their original value (which we need for serialization purposes)
Public Types | |
| using | second_type = ValueString |
| using | first_type = sourcemeta::core::Regex |
Public Member Functions | |
| auto | to_json () const -> sourcemeta::core::JSON |
Static Public Member Functions | |
| static auto | from_json (const sourcemeta::core::JSON &value) -> std::optional< ValueRegex > |
Public Attributes | |
| first_type | first |
| second_type | second |
A callback of this type is invoked after evaluating any keyword. The arguments go as follows:
You can use this callback mechanism to implement arbitrary output formats.
| using sourcemeta::blaze::Instructions = std::vector<Instruction> |
Represents a set of schema compilation steps that can be evaluated
| using sourcemeta::blaze::Value |
| using sourcemeta::blaze::ValueBoolean = bool |
Represents a compiler step boolean value
| using sourcemeta::blaze::ValueIndexPair = std::pair<std::size_t, std::size_t> |
Represents a compiler step value that consists of two indexes
| using sourcemeta::blaze::ValueIntegerBounds = std::pair<std::int64_t, std::int64_t> |
Represents integer bounds with minimum and maximum
| using sourcemeta::blaze::ValueIntegerBoundsWithSize = std::pair<ValueIntegerBounds, ValueRange> |
Represents integer bounds combined with array size range
| using sourcemeta::blaze::ValueJSON = sourcemeta::core::JSON |
Represents a compiler step JSON value
Represents the precomputed hash of a property name, the index of the child instruction that applies to it, and the name itself. The hash comes first as it is what a lookup compares against
Represents a compiler step string to index map. The entries are sorted by the size of the name, and the table of contents gives, for every name size, the one-based inclusive range of entries that have that size, so that a lookup only ever compares the names whose size can match
Represents a list of object property entries: (name, hash, required)
| using sourcemeta::blaze::ValuePointer = sourcemeta::core::Pointer |
Represents a compiler step value that consists of a pointer
Represents a compiler step object property value
Represents a compiler step value that consist of object property filters (strings, prefixes, regexes)
| using sourcemeta::blaze::ValueRange = std::tuple<std::size_t, std::optional<std::size_t>, bool> |
Represents a compiler step range value. The boolean option modifies whether the range is considered exhaustively or if the evaluator is allowed to break early
Represents a set of JSON values
| using sourcemeta::blaze::ValueString = sourcemeta::core::JSON::String |
Represents a compiler step string value
Represents a compiler step types property hashes value
Represents an compiler step that maps strings to strings
| using sourcemeta::blaze::ValueStrings = std::vector<ValueString> |
Represents a compiler step string values
| using sourcemeta::blaze::ValueStringSet = sourcemeta::core::JSONPropertySet |
Represents a compiler step string set of values
| using sourcemeta::blaze::ValueType = sourcemeta::core::JSON::Type |
Represents a compiler step JSON type value
| using sourcemeta::blaze::ValueTypedHashes = std::pair<ValueType, ValueStringHashes> |
Represents a compiler step types property hashes value
| using sourcemeta::blaze::ValueTypedProperties = std::pair<ValueType, ValueStringSet> |
Represents a compiler step types properties value
| using sourcemeta::blaze::ValueTypes = sourcemeta::core::JSON::TypeSet |
Represents a compiler step JSON types value as a bitmask
| using sourcemeta::blaze::ValueTypesWithSize = std::pair<ValueTypes, ValueRange> |
Represents a set of types combined with an array size range
| using sourcemeta::blaze::ValueUnsignedInteger = std::size_t |
Represents a compiler step JSON unsigned integer value
|
strong |
Represents the state of an instruction evaluation
|
strong |
|
strong |
Represents a compiler step number logical type
|
strong |
Represents a compiler step string logical type
| auto sourcemeta::blaze::describe | ( | const Template & | schema_template, |
| const bool | valid, | ||
| const Instruction & | step, | ||
| const sourcemeta::core::WeakPointer & | evaluate_path, | ||
| const sourcemeta::core::WeakPointer & | instance_location, | ||
| const sourcemeta::core::JSON & | instance, | ||
| const sourcemeta::core::JSON & | annotation )->std::string |
This function translates a "post" step execution into a human-readable string. Useful as the building block for producing user-friendly evaluation results.
Note that describing a "pre" step execution is NOT supported.
| auto sourcemeta::blaze::from_json | ( | const sourcemeta::core::JSON & | json | ) | ->std::optional< Template > |
Parse a template from JSON
|
inlinenoexcept |
Check if a given instruction type corresponds to an annotation
|
inlinenoexcept |
Check if a given instruction type corresponds to a wrapped annotation