dist/@ajsf/core/esm2015/lib/shared/jsonpointer.functions.js
/**
     * 'toSchemaPointer' function
     *
     * Accepts a JSON Pointer to a value inside a data object and a JSON schema
     * for that object.
     *
     * Returns a Pointer to the sub-schema for the value inside the object's schema.
     *
     * //  { Pointer } dataPointer - JSON Pointer (string or array) to an object
     * //   schema - JSON schema for the object
     * // { Pointer } - JSON Pointer (string) to the object's schema
     */
'toSchemaPointer' function
Accepts a JSON Pointer to a value inside a data object and a JSON schema
for that object.

Returns a Pointer to the sub-schema for the value inside the object's schema.

{ Pointer } dataPointer - JSON Pointer (string or array) to an object
schema - JSON schema for the object
{ Pointer } - JSON Pointer (string) to the object's schema
' toSchemaPointer ' function Accepts a JSON Pointer to a value inside a data object and a JSON schema for that object . Returns a Pointer to the sub - schema for the value inside the object ' s schema . { Pointer } dataPointer - JSON Pointer ( string or array ) to an object schema - JSON schema for the object { Pointer } - JSON Pointer ( string ) to the object ' s schema
static toSchemaPointer(dataPointer, schema) {
        if (this.isJsonPointer(dataPointer) && typeof schema === 'object') {
            const pointerArray = this.parse(dataPointer);
            if (!pointerArray.length) {
                return '';
            }
            const firstKey = pointerArray.shift();
            if (schema.type === 'object' || schema.properties || schema.additionalProperties) {
                if ((schema.properties || {})[firstKey]) {
                    return `/properties/${this.escape(firstKey)}` +
                        this.toSchemaPointer(pointerArray, schema.properties[firstKey]);
                }
                else if (schema.additionalProperties) {
                    return '/additionalProperties' +
                        this.toSchemaPointer(pointerArray, schema.additionalProperties);
                }
            }
            if ((schema.type === 'array' || schema.items) &&
                (isNumber(firstKey) || firstKey === '-' || firstKey === '')) {
                const arrayItem = firstKey === '-' || firstKey === '' ? 0 : +firstKey;
                if (isArray(schema.items)) {
                    if (arrayItem < schema.items.length) {
                        return '/items/' + arrayItem +
                            this.toSchemaPointer(pointerArray, schema.items[arrayItem]);
                    }
                    else if (schema.additionalItems) {
                        return '/additionalItems' +
                            this.toSchemaPointer(pointerArray, schema.additionalItems);
                    }
                }
                else if (isObject(schema.items)) {
                    return '/items' + this.toSchemaPointer(pointerArray, schema.items);
                }
                else if (isObject(schema.additionalItems)) {
                    return '/additionalItems' +
                        this.toSchemaPointer(pointerArray, schema.additionalItems);
                }
            }
            console.error(`toSchemaPointer error: Data pointer ${dataPointer} ` +
                `not compatible with schema ${schema}`);
            return null;
        }
        if (!this.isJsonPointer(dataPointer)) {
            console.error(`toSchemaPointer error: Invalid JSON Pointer: ${dataPointer}`);
        }
        if (typeof schema !== 'object') {
            console.error(`toSchemaPointer error: Invalid JSON Schema: ${schema}`);
        }
        return null;
    }
static toSchemaPointer ( dataPointer , schema ) { if ( this . isJsonPointer ( dataPointer ) && typeof schema === 'object' ) { const pointerArray = this . parse ( dataPointer ) ; if ( ! pointerArray . length ) { return '' ; } const firstKey = pointerArray . shift ( ) ; if ( schema . type === 'object' || schema . properties || schema . additionalProperties ) { if ( ( schema . properties || { } ) [ firstKey ] ) { return ` ${ this . escape ( firstKey ) } ` + this . toSchemaPointer ( pointerArray , schema . properties [ firstKey ] ) ; } else if ( schema . additionalProperties ) { return '/additionalProperties' + this . toSchemaPointer ( pointerArray , schema . additionalProperties ) ; } } if ( ( schema . type === 'array' || schema . items ) && ( isNumber ( firstKey ) || firstKey === '-' || firstKey === '' ) ) { const arrayItem = firstKey === '-' || firstKey === '' ? 0 : + firstKey ; if ( isArray ( schema . items ) ) { if ( arrayItem < schema . items . length ) { return '/items/' + arrayItem + this . toSchemaPointer ( pointerArray , schema . items [ arrayItem ] ) ; } else if ( schema . additionalItems ) { return '/additionalItems' + this . toSchemaPointer ( pointerArray , schema . additionalItems ) ; } } else if ( isObject ( schema . items ) ) { return '/items' + this . toSchemaPointer ( pointerArray , schema . items ) ; } else if ( isObject ( schema . additionalItems ) ) { return '/additionalItems' + this . toSchemaPointer ( pointerArray , schema . additionalItems ) ; } } console . error ( ` ${ dataPointer } ` + ` ${ schema } ` ) ; return null ; } if ( ! this . isJsonPointer ( dataPointer ) ) { console . error ( ` ${ dataPointer } ` ) ; } if ( typeof schema !== 'object' ) { console . error ( ` ${ schema } ` ) ; } return null ; }
'toSchemaPointer' function
 Accepts a JSON Pointer to a value inside a data object and a JSON schema
 for that object.
' toSchemaPointer ' function Accepts a JSON Pointer to a value inside a data object and a JSON schema for that object .