Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Class

JsonSchema

OfficeIMO.Json

Namespace
OfficeIMO.Json
Assembly
OfficeIMO.Core
Source revision
ba882f6b0d07 with working tree changes
Modifiers
sealed

A JSON Schema (draft 2020-12 or draft 7) that validates JsonData values, such as the contents of a YAML, TOML or JSON configuration file. Findings carry the JSON Pointer of the value, the schema path of the failing keyword, and the value's line and column in the source.

Inheritance

  • object
  • JsonSchema

Remarks

Supported keywords: type, enum, const; multipleOf, minimum, maximum, exclusiveMinimum, exclusiveMaximum; minLength, maxLength, pattern, format; prefixItems, items, contains, minContains, maxContains, minItems, maxItems, uniqueItems, unevaluatedItems; properties, patternProperties, additionalProperties, propertyNames, required, minProperties, maxProperties, dependentRequired, dependentSchemas, unevaluatedProperties; allOf, anyOf, oneOf, not, if/then/else; $ref, $dynamicRef, $defs, $id, $anchor and $dynamicAnchor. Draft 7 schemas also read definitions, array items with additionalItems, and dependencies. Other keywords, including $vocabulary and the content keywords, are annotations only. References resolve within the loaded document; anything else goes to , and nothing is fetched otherwise. Patterns use .NET regular expressions with a timeout. A loaded schema is safe to use from several threads.

Usage

Explore 2 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Returned or exposed by 2

Methods

public bool IsValid(JsonData instance) #

Returns whether a value matches, stopping at the first finding.

Parameters

instance OfficeIMO.Json.JsonData required

Returns

bool

Exceptions

  • ArgumentNullException – instance is null.
  • JsonSchemaException – A referenced part of the schema is not valid.
public static JsonSchema Load(JsonData schema, JsonSchemaOptions? options = null) #

Loads a schema from a JSON value, such as one converted from a YAML document.

Parameters

schema OfficeIMO.Json.JsonData required
options OfficeIMO.Json.JsonSchemaOptions? = null optional

Returns

JsonSchema

Exceptions

public static JsonSchema Parse(string json, JsonSchemaOptions? options = null) #

Parses a schema from JSON text.

Parameters

json string required
options OfficeIMO.Json.JsonSchemaOptions? = null optional

Returns

JsonSchema

Exceptions

public JsonSchemaValidationResult Validate(JsonData instance) #

Validates a value, reporting every finding up to JsonSchemaOptions.MaxErrors.

Parameters

instance OfficeIMO.Json.JsonData required

Exceptions

  • ArgumentNullException – instance is null.
  • JsonSchemaException – A referenced part of the schema is not valid.

Properties

public JsonSchemaDraft Draft { get; } #

Gets the dialect the schema is read with.

public JsonData Root { get; } #

Gets the schema as loaded.