dist/@ajsf/core/esm2015/lib/shared/jsonpointer.functions.js
/**
     * 'toDataPointer' function
     *
     * Accepts a JSON Pointer to a sub-schema inside a JSON schema and the schema.
     *
     * If possible, returns a generic Pointer to the corresponding value inside
     * the data object described by the JSON schema.
     *
     * Returns null if the sub-schema is in an ambiguous location (such as
     * definitions or additionalProperties) where the corresponding value
     * location cannot be determined.
     *
     * //  { Pointer } schemaPointer - JSON Pointer (string or array) to a JSON schema
     * //   schema - the JSON schema
     * //  { boolean = false } errors - Show errors?
     * // { Pointer } - JSON Pointer (string) to the value in the data object
     */
'toDataPointer' function
Accepts a JSON Pointer to a sub-schema inside a JSON schema and the schema.

If possible, returns a generic Pointer to the corresponding value inside
the data object described by the JSON schema.

Returns null if the sub-schema is in an ambiguous location (such as
definitions or additionalProperties) where the corresponding value
location cannot be determined.

{ Pointer } schemaPointer - JSON Pointer (string or array) to a JSON schema
schema - the JSON schema
{ boolean = false } errors - Show errors.
{ Pointer } - JSON Pointer (string) to the value in the data object
' toDataPointer ' function Accepts a JSON Pointer to a sub - schema inside a JSON schema and the schema . If possible returns a generic Pointer to the corresponding value inside the data object described by the JSON schema . Returns null if the sub - schema is in an ambiguous location ( such as definitions or additionalProperties ) where the corresponding value location cannot be determined . { Pointer } schemaPointer - JSON Pointer ( string or array ) to a JSON schema schema - the JSON schema { boolean = false } errors - Show errors . { Pointer } - JSON Pointer ( string ) to the value in the data object
static toDataPointer(schemaPointer, schema, errors = false) {
        if (this.isJsonPointer(schemaPointer) && typeof schema === 'object' &&
            this.has(schema, schemaPointer)) {
            const pointerArray = this.parse(schemaPointer);
            if (!pointerArray.length) {
                return '';
            }
            const firstKey = pointerArray.shift();
            if (firstKey === 'properties' ||
                (firstKey === 'items' && isArray(schema.items))) {
                const secondKey = pointerArray.shift();
                const pointerSuffix = this.toDataPointer(pointerArray, schema[firstKey][secondKey]);
                return pointerSuffix === null ? null : '/' + secondKey + pointerSuffix;
            }
            else if (firstKey === 'additionalItems' ||
                (firstKey === 'items' && isObject(schema.items))) {
                const pointerSuffix = this.toDataPointer(pointerArray, schema[firstKey]);
                return pointerSuffix === null ? null : '/-' + pointerSuffix;
            }
            else if (['allOf', 'anyOf', 'oneOf'].includes(firstKey)) {
                const secondKey = pointerArray.shift();
                return this.toDataPointer(pointerArray, schema[firstKey][secondKey]);
            }
            else if (firstKey === 'not') {
                return this.toDataPointer(pointerArray, schema[firstKey]);
            }
            else if (['contains', 'definitions', 'dependencies', 'additionalItems',
                'additionalProperties', 'patternProperties', 'propertyNames'].includes(firstKey)) {
                if (errors) {
                    console.error(`toDataPointer error: Ambiguous location`);
                }
            }
            return '';
        }
        if (errors) {
            if (!this.isJsonPointer(schemaPointer)) {
                console.error(`toDataPointer error: Invalid JSON Pointer: ${schemaPointer}`);
            }
            if (typeof schema !== 'object') {
                console.error(`toDataPointer error: Invalid JSON Schema: ${schema}`);
            }
            if (typeof schema !== 'object') {
                console.error(`toDataPointer error: Pointer ${schemaPointer} invalid for Schema: ${schema}`);
            }
        }
        return null;
    }
static toDataPointer ( schemaPointer , schema , errors = false ) { if ( this . isJsonPointer ( schemaPointer ) && typeof schema === 'object' && this . has ( schema , schemaPointer ) ) { const pointerArray = this . parse ( schemaPointer ) ; if ( ! pointerArray . length ) { return '' ; } const firstKey = pointerArray . shift ( ) ; if ( firstKey === 'properties' || ( firstKey === 'items' && isArray ( schema . items ) ) ) { const secondKey = pointerArray . shift ( ) ; const pointerSuffix = this . toDataPointer ( pointerArray , schema [ firstKey ] [ secondKey ] ) ; return pointerSuffix === null ? null : '/' + secondKey + pointerSuffix ; } else if ( firstKey === 'additionalItems' || ( firstKey === 'items' && isObject ( schema . items ) ) ) { const pointerSuffix = this . toDataPointer ( pointerArray , schema [ firstKey ] ) ; return pointerSuffix === null ? null : '/-' + pointerSuffix ; } else if ( [ 'allOf' , 'anyOf' , 'oneOf' ] . includes ( firstKey ) ) { const secondKey = pointerArray . shift ( ) ; return this . toDataPointer ( pointerArray , schema [ firstKey ] [ secondKey ] ) ; } else if ( firstKey === 'not' ) { return this . toDataPointer ( pointerArray , schema [ firstKey ] ) ; } else if ( [ 'contains' , 'definitions' , 'dependencies' , 'additionalItems' , 'additionalProperties' , 'patternProperties' , 'propertyNames' ] . includes ( firstKey ) ) { if ( errors ) { console . error ( ` ` ) ; } } return '' ; } if ( errors ) { if ( ! this . isJsonPointer ( schemaPointer ) ) { console . error ( ` ${ schemaPointer } ` ) ; } if ( typeof schema !== 'object' ) { console . error ( ` ${ schema } ` ) ; } if ( typeof schema !== 'object' ) { console . error ( ` ${ schemaPointer } ${ schema } ` ) ; } } return null ; }
'toDataPointer' function
 Accepts a JSON Pointer to a sub-schema inside a JSON schema and the schema.
' toDataPointer ' function Accepts a JSON Pointer to a sub - schema inside a JSON schema and the schema .