How to use json-schema-library - 10 common examples

To help you get started, we’ve selected a few json-schema-library examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sueddeutsche / editron / services / SchemaService.js View on Github external
get(pointer, data) {
        if (data) {
            const result = jsl.getSchema(this.core, pointer, data, this.schema);
            return copy(result);
        }

        if (this.cache[pointer] === undefined) {
            const result = jsl.getSchema(this.core, pointer, this.data, this.schema);
            if (result.variableSchema === true) {
                // @special case: do not cache dynamic schema object (oneOf)
                return result;
            }
            this.cache[pointer] = copy(result);
        }

        return this.cache[pointer];
    }
github sueddeutsche / editron / services / SchemaService.js View on Github external
get(pointer, data) {
        if (data) {
            const result = jsl.getSchema(this.core, pointer, data, this.schema);
            return copy(result);
        }

        if (this.cache[pointer] === undefined) {
            const result = jsl.getSchema(this.core, pointer, this.data, this.schema);
            if (result.variableSchema === true) {
                // @special case: do not cache dynamic schema object (oneOf)
                return result;
            }
            this.cache[pointer] = copy(result);
        }

        return this.cache[pointer];
    }
github sueddeutsche / editron / utils / UISchema.js View on Github external
function extendSchema(rootSchema) {
    rootSchema = JSON.parse(JSON.stringify(rootSchema));
    eachSchema(rootSchema, childSchema => {
        childSchema[UI_PROPERTY] = childSchema[UI_PROPERTY] || {};
        childSchema[UI_PROPERTY] = Object.assign({
            hidden: false,
            title: childSchema.title || "",
            description: childSchema.description || ""
        }, childSchema.options, childSchema[UI_PROPERTY]); // @legacy options
    });

    return rootSchema;
}
github ebdrup / json-schema-benchmark / index.js View on Github external
setup: function (schema) {
			return new jlib.cores.Draft04(schema);
		},
		test: function (instance, json, schema) {
github sueddeutsche / editron / services / SchemaService.js View on Github external
const Core = require("json-schema-library").cores.JsonEditor;
const copy = require("./utils/copy");
const jsl = require("json-schema-library");
const getChildSchemaSelection = require("json-schema-library").getChildSchemaSelection;


/**
 * Manages json-schema interactions and adds caching of reoccuring json-schema requests
 *
 * @param {Object} schema       - json-schema
 * @param {Object} [data={}]    - data corresponding to json-schema
 * @param {Core} [core={}]      - instance of json-schema-library Core
 */
class SchemaService {

    constructor(schema = {}, data = {}, core = new Core()) {
        this.core = core;
github sueddeutsche / editron / Controller.js View on Github external
const gp = require("gson-pointer");
const Core = require("json-schema-library").cores.JsonEditor;
const addValidator = require("json-schema-library/lib/addValidator");
const DataService = require("./services/DataService");
const SchemaService = require("./services/SchemaService");
const ValidationService = require("./services/ValidationService");
const LocationService = require("./services/LocationService");
const State = require("./services/State");
const selectEditor = require("./utils/selectEditor");
const _createElement = require("./utils/createElement");
const addItem = require("./utils/addItem");
const UISchema = require("./utils/UISchema");
const getID = require("./utils/getID");
const plugin = require("./plugin");
const i18n = require("./utils/i18n");


function isValidPointer(pointer) {
github sueddeutsche / editron / services / ValidationService.js View on Github external
const mitt = require("mitt");
const Core = require("json-schema-library").cores.JsonEditor;
const State = require("./State");
const ActionCreators = require("./reducers/actions").ActionCreators;
const errorReducer = require("./reducers/errorReducer");
const Validation = require("./utils/Validation");
const BubblingCollectionObservable = require("./utils/BubblingCollectionObservable");


const EVENTS = {
    BEFORE_VALIDATION: "beforeValidation",
    AFTER_VALIDATION: "afterValidation",
    ON_ERROR: "onError"
};


/**
 * @class  ValidationService
github sueddeutsche / editron / Controller.js View on Github external
addFormatValidator(format, validator) {
        addValidator.format(this.core, format, validator);
    }
github sueddeutsche / editron / Controller.js View on Github external
addKeywordValidator(datatype, keyword, validator) {
        addValidator.keyword(this.core, datatype, keyword, validator);
    }
github ebdrup / json-schema-benchmark / index.js View on Github external
Object.keys(refs).forEach(function (uri) {
    ajv.addSchema(refs[uri], uri);
    djv.addSchema(uri, refs[uri]);
    jlib.addSchema(uri, refs[uri]);
});

json-schema-library

Customizable and hackable json-validator and json-schema utilities for traversal, data generation and validation

MIT
Latest version published 20 days ago

Package Health Score

68 / 100
Full package analysis