Skip to main content

@versionzero/schema / SchemaLocation

Class: SchemaLocation

Defined in: src/schema-location.js:13

The SchemaLocation tracks the schema and parent/child relationships for a given traversal path.

Schemas can be linked into a hierarchy in multiple positions, so they have no static "parent". However, traversal builds an implicit hierarchy of locations that each then refer to a schema (if known), enabling access to any schema within the location hierarchy, including the parent.

The current location is passed to value processors, effectively acting as a sort of "cursor".

Constructors​

Constructor​

new SchemaLocation(schema, parent?, propertyName?): SchemaLocation

Defined in: src/schema-location.js:31

Parameters​

ParameterTypeDescription
schemaCompiledSchema-
parent?SchemaLocation-
propertyName?string-

Returns​

SchemaLocation

Accessors​

path​

Get Signature​

get path(): string

Defined in: src/schema-location.js:43

Returns​

string


name​

Get Signature​

get name(): string

Defined in: src/schema-location.js:52

Returns​

string


schema​

Get Signature​

get schema(): CompiledSchema

Defined in: src/schema-location.js:58

Returns​

CompiledSchema


parent​

Get Signature​

get parent(): SchemaLocation | undefined

Defined in: src/schema-location.js:79

Returns​

SchemaLocation | undefined


root​

Get Signature​

get root(): SchemaLocation

Defined in: src/schema-location.js:84

Returns​

SchemaLocation

Methods​

relative()​

relative(path): SchemaLocation | undefined

Defined in: src/schema-location.js:94

Return the location of the path relative to the current location.

Parameters​

ParameterTypeDescription
pathstring-

Returns​

SchemaLocation | undefined


absolute()​

absolute(path): SchemaLocation | undefined

Defined in: src/schema-location.js:138

Return the location of the path relative to the root of the known location hierarchy.

Parameters​

ParameterTypeDescription
pathstring-

Returns​

SchemaLocation | undefined


sibling()​

sibling(path): SchemaLocation | undefined

Defined in: src/schema-location.js:148

Return the location of a sibling with the relative path.

Parameters​

ParameterTypeDescription
pathstring-

Returns​

SchemaLocation | undefined


union()​

union(unionSchema): SchemaLocation | undefined

Defined in: src/schema-location.js:161

Return a temporary location corresponding to one of our not-yet-resolved union members.

Parameters​

ParameterTypeDescription
unionSchemaCompiledSchema-

Returns​

SchemaLocation | undefined


findPropertyLocation()​

findPropertyLocation(predicate): SchemaLocation | undefined

Defined in: src/schema-location.js:184

Parameters​

ParameterTypeDescription
predicate(location) => any-

Returns​

SchemaLocation | undefined