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 |
| class | sourcemeta::blaze::StringSet |
| 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 , AssertionStringType , AssertionPropertyType , AssertionPropertyTypeEvaluate , AssertionPropertyTypeStrict , AssertionPropertyTypeStrictEvaluate , AssertionPropertyTypeStrictAny , AssertionPropertyTypeStrictAnyEvaluate , AssertionArrayPrefix , AssertionArrayPrefixEvaluate , AssertionObjectPropertiesSimple , AnnotationEmit , 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 , 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 } |
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::describe (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 {5} |
| constexpr std::string_view | sourcemeta::blaze::InstructionNames [] |
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 |
| 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 |
| 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 |
| class sourcemeta::blaze::StringSet |
Public Types | |
| using | string_type = sourcemeta::core::JSON::String |
| using | hash_type = sourcemeta::core::JSON::Object::hash_type |
| using | value_type = std::pair< string_type, hash_type > |
| using | underlying_type = std::vector< value_type > |
| using | size_type = typename underlying_type::size_type |
| using | difference_type = typename underlying_type::difference_type |
| using | const_iterator = typename underlying_type::const_iterator |
Public Member Functions | |
| auto | contains (const string_type &value, const hash_type hash) const -> bool |
| auto | contains (const string_type &value) const -> bool |
| auto | at (const size_type index) const noexcept -> const value_type & |
| auto | insert (const string_type &value) -> void |
| auto | insert (string_type &&value) -> void |
| auto | empty () const noexcept -> bool |
| auto | size () const noexcept -> size_type |
| auto | begin () const -> const_iterator |
| auto | end () const -> const_iterator |
| auto | cbegin () const -> const_iterator |
| auto | cend () const -> const_iterator |
| auto | to_json () const -> sourcemeta::core::JSON |
Static Public Member Functions | |
| static auto | from_json (const sourcemeta::core::JSON &value) -> std::optional< StringSet > |
| 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 |
| using sourcemeta::blaze::Callback = typedef std::function<void( const EvaluationType, bool, const Instruction &, const InstructionExtra &, const sourcemeta::core::WeakPointer &, const sourcemeta::core::WeakPointer &, const sourcemeta::core::JSON &)> |
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 = typedef std::vector<Instruction> |
Represents a set of schema compilation steps that can be evaluated
| using sourcemeta::blaze::ValueBoolean = typedef bool |
Represents a compiler step boolean value
| using sourcemeta::blaze::ValueIndexPair = typedef std::pair<std::size_t, std::size_t> |
Represents a compiler step value that consists of two indexes
| using sourcemeta::blaze::ValueIntegerBounds = typedef std::pair<std::int64_t, std::int64_t> |
Represents integer bounds with minimum and maximum
| using sourcemeta::blaze::ValueIntegerBoundsWithSize = typedef std::pair<ValueIntegerBounds, ValueRange> |
Represents integer bounds combined with array size range
| using sourcemeta::blaze::ValueJSON = typedef sourcemeta::core::JSON |
Represents a compiler step JSON value
| using sourcemeta::blaze::ValueNamedIndexes = typedef sourcemeta::core::JSONObject< ValueString, ValueUnsignedInteger, sourcemeta::core::PropertyHashJSON<ValueString> > |
Represents a compiler step string to index map
| using sourcemeta::blaze::ValueObjectProperties = typedef std::vector< std::tuple<ValueString, sourcemeta::core::JSON::Object::hash_type, bool> > |
Represents a list of object property entries: (name, hash, required)
| using sourcemeta::blaze::ValuePointer = typedef sourcemeta::core::Pointer |
Represents a compiler step value that consists of a pointer
| using sourcemeta::blaze::ValueProperty = typedef std::pair<ValueString, sourcemeta::core::JSON::Object::hash_type> |
Represents a compiler step object property value
| using sourcemeta::blaze::ValuePropertyFilter = typedef std::tuple<ValueStringSet, ValueStrings, std::vector<ValueRegex> > |
Represents a compiler step value that consist of object property filters (strings, prefixes, regexes)
| using sourcemeta::blaze::ValueRange = typedef 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
| using sourcemeta::blaze::ValueSet = typedef std::unordered_set<sourcemeta::core::JSON, sourcemeta::core::HashJSON<sourcemeta::core::JSON> > |
Represents a set of JSON values
| using sourcemeta::blaze::ValueString = typedef sourcemeta::core::JSON::String |
Represents a compiler step string value
| using sourcemeta::blaze::ValueStringHashes = typedef std::pair<std::vector<std::pair<ValueStringSet::hash_type, ValueString> >, std::vector<ValueIndexPair> > |
Represents a compiler step types property hashes value
| using sourcemeta::blaze::ValueStringMap = typedef sourcemeta::core::JSONObject< ValueString, ValueStrings, sourcemeta::core::PropertyHashJSON<ValueString> > |
Represents an compiler step that maps strings to strings
| using sourcemeta::blaze::ValueStrings = typedef std::vector<ValueString> |
Represents a compiler step string values
| using sourcemeta::blaze::ValueStringSet = typedef StringSet |
Represents a compiler step string set of values
| using sourcemeta::blaze::ValueType = typedef sourcemeta::core::JSON::Type |
Represents a compiler step JSON type value
| using sourcemeta::blaze::ValueTypedHashes = typedef std::pair<ValueType, ValueStringHashes> |
Represents a compiler step types property hashes value
| using sourcemeta::blaze::ValueTypedProperties = typedef std::pair<ValueType, ValueStringSet> |
Represents a compiler step types properties value
| using sourcemeta::blaze::ValueTypes = typedef sourcemeta::core::JSON::TypeSet |
Represents a compiler step JSON types value as a bitmask
| using sourcemeta::blaze::ValueUnsignedInteger = typedef 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 string logical type
| auto sourcemeta::blaze::describe | ( | 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