final case class Context(baseUri: URI, path: JsonPointer, schemaPath: JsonPointer, readOnly: Boolean, refs: Refs, formats: Formats) extends Product with Serializable
Contains context information as validator is executed.
When schema validation is invoked the JSON Schema document is
traversed and as the traversal occurs the JSON data is matched against
the relevant constraints. The traversal of the Schema document needs
to track the current base URI so it can resolve relative $id
properties in the document itself. The paths of the current constraint
and data are also maintained so that error messages can indicate
the location within the data and also the location of the constraint
of a failure.
Other environment based information is kept to avoid passing
implicit values to all validation methods. The information includes
whether readOnly
properties should be honoured and also a
partial function used to validate format
properties.
Since the context is only used internally by the validation routines it is declare to be private within the project.
- baseUri
for the current JSON Schema node
- path
of the current JSON data node
- schemaPath
of the current JSON Schema node
- readOnly
true
if thereadOnly
property should be honoured- refs
map containing reference resolution entries
- formats
partial function used to validate
format
properties
- Source
- Context.scala
- Alphabetic
- By Inheritance
- Context
- Serializable
- Product
- Equals
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new Context(baseUri: URI, path: JsonPointer, schemaPath: JsonPointer, readOnly: Boolean, refs: Refs, formats: Formats)
- baseUri
for the current JSON Schema node
- path
of the current JSON data node
- schemaPath
of the current JSON Schema node
- readOnly
true
if thereadOnly
property should be honoured- refs
map containing reference resolution entries
- formats
partial function used to validate
format
properties
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##(): Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def appendPath(token: String): Context
Appends a new path component to the current data path.
Appends a new path component to the current data path.
The JSON data path is updated as it is traversed. When a JSON object is encountered each property needs to be appended to the parent path so that the path for the current node is correct.
- token
path component to append to existing JSON data path
- returns
new Context containing updated data path
- def appendPath(index: Int): Context
Appends a new array index to the current data path.
Appends a new array index to the current data path.
When traversing the JSON data and an array is encountered, the index of the current array node being processed is added to the current data path.
- index
of the array entry to append to the current data path
- returns
new Context containing updated data path
- def appendSchemaPath(token: String): Context
Appends a new path component to the current schema path.
Appends a new path component to the current schema path.
The JSON schema path is updated as the schema is traversed. When a JSON object is encountered the current property is appended to the schema path as its assertions are evaluated.
- token
path component to append to existing JSON schema path
- returns
new Context containing updated schema path
- def appendSchemaPath(index: Int): Context
Appends a new array index to the current schema path.
Appends a new array index to the current schema path.
When the JSON schema is traversed the path of the current node is maintained. In the case of an array an index into the current entry is appended to the existing path.
- index
of the array entry to append to the current schema path
- returns
new Context containing updated schema path
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- val baseUri: URI
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- val formats: Formats
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- val path: JsonPointer
- def productElementNames: Iterator[String]
- Definition Classes
- Product
- val readOnly: Boolean
- val refs: Refs
- val schemaPath: JsonPointer
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- def withId(uri: URI): Context
Updates the base URI within the Context.
Documentation for the Axiell Schema Project
Overview
The Axiell Schema Project provides a small library for validating JSON documents against a JSON Schema. The library conforms to the JSON Schema Draft #7 specification.
The library is based on a few simple principles, namely:
Package structure
The
packages consists of a number of utilities, where each utility provides a single piece of functionality. Since the library validates JSON structures two main components are provided. The first component (com.axiell.schema
) allows JSON documents conforming to the JSON Schema specification to be read. Once read a resolution process may be required to resolve any external references defined in the document.com.axiell.schema.Schema
The second component (
) takes a resolved schema and allows JSON documents to be validated against that schema. When creating a validator it is also possible to incorporate your own "format" types for validation.com.axiell.schema.SchemaValidator
A set of auxiliary components implement parsers for many of the "format" types and can be used independently of the validator itself.
Notable utilities are:
Schema
wrapper around a JSON document containing the document itself, its$id
value and resolution mappings for all$id
and$ref
directives.SchemaValidator
takes aSchema
and an optional handler for "format" types and provides a validation method for arbitrary JSON documents.Implicits
implements implicit methods and classes used to convert one class to another or pimp methods onto existing classes (e.g.same()
method toJValue
class).EmailAddress
Hostname
Ipv4Address
Ipv6Address
JsonPointer
RelativeJsonPointer
Dependencies
The list of dependencies are:
Axiell Util Library
provides error handling classes and methods that allow multilingual error messages to be generated.JSON for Scala Library
provides mthods for dealing with JSON structures. The routines work around an AST (Abstract Syntax Tree) used to represent a JSON document.Cats Functional Programming Library
provides various traits, classes and methods that simplify functional programming in Scala. Also provides theValidated
class used to return lists of validation errors.