Module: JSONSchema

Defined in:
lib/jsonschema/version.rb,
sig/jsonschema.rbs

Defined Under Namespace

Modules: Canonical, Meta Classes: Draft201909Validator, Draft202012Validator, Draft4Validator, Draft6Validator, Draft7Validator, EmailOptions, Evaluation, FancyRegexOptions, HttpOptions, ReferencingError, RegexOptions, Registry, Resolved, Resolver, ValidationError, ValidationErrorKind, Validator, ValidatorMap

Constant Summary collapse

VERSION =

Returns:

  • (String)
"0.49.1"

Class Method Summary collapse

Class Method Details

.bundleObject

Bundle a JSON Schema into a Compound Schema Document. All externally-referenced schemas reachable via $ref are embedded in a draft-appropriate container (definitions for Draft 4/6/7, $defs for Draft 2019-09/2020-12). Original $ref values are preserved unchanged.



220
# File 'sig/jsonschema.rbs', line 220

def self.bundle: (

.canonicalizeObject

Reduce a schema to its canonical form.



167
# File 'sig/jsonschema.rbs', line 167

def self.canonicalize: (

.dereferenceObject

Dereference a JSON Schema by recursively replacing all $ref values with the schemas they point to.



230
# File 'sig/jsonschema.rbs', line 230

def self.dereference: (

.each_errorObject

Iterate validation errors. Returns Array when no block given, nil when block given.



279
# File 'sig/jsonschema.rbs', line 279

def self.each_error: (

.evaluateObject

One-off evaluation returning structured output.



313
# File 'sig/jsonschema.rbs', line 313

def self.evaluate: (

.valid?Object

One-off validation returning boolean.



243
# File 'sig/jsonschema.rbs', line 243

def self.valid?: (

.validate!Object

One-off validation raising on error.



261
# File 'sig/jsonschema.rbs', line 261

def self.validate!: (

.validator_cls_forsingleton(Draft4Validator), ...

Detect the JSON Schema draft for a schema and return the corresponding validator class. Draft is detected automatically from the $schema field. Defaults to Draft202012Validator.

Parameters:

  • schema (Object)

Returns:



240
# File 'sig/jsonschema.rbs', line 240

def self.validator_cls_for: (untyped schema) -> (singleton(Draft4Validator) | singleton(Draft6Validator) | singleton(Draft7Validator) | singleton(Draft201909Validator) | singleton(Draft202012Validator))

.validator_forObject

Create a validator with auto-detected draft version.

Parameters:

  • schema

    The JSON Schema (Hash or JSON string)

  • validate_formats

    Enable format validation

  • ignore_unknown_formats

    Ignore unknown formats

  • base_uri

    Base URI for reference resolution

  • retriever

    Custom schema retriever proc

  • mask

    Mask sensitive data in error messages

  • formats

    Custom format validators (Hash of format_name => proc)

  • keywords

    Custom keyword validators (Hash of keyword_name => class)



184
# File 'sig/jsonschema.rbs', line 184

def self.validator_for: (

.validator_map_forObject

Create a map of validators for all sub-schemas in a JSON Schema.



200
# File 'sig/jsonschema.rbs', line 200

def self.validator_map_for: (