How to use the json-schema.validate function in json-schema

To help you get started, we’ve selected a few json-schema 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 DefinitelyTyped / DefinitelyTyped / types / json-schema / json-schema-tests.ts View on Github external
readOnly: false,
        writeOnly: false,
        contentEncoding: 'base64',
        contentMediaType: 'text',
        else: {},
        if: {},
        then: {}
    }
    const c: JSONSchema7Definition = false;
}

// Class
class Schema7 implements JSONSchema7 {
}

let result = validate({}, { $id: 'schema-id' });
mustBeValid(result);

result = checkPropertyChange({ foo: 'bar' }, { $id: 'schema-id' }, 'foo');
github splunk / splunk-aws-project-trumpet / cloudtrail-serverless / lambda_code / cloudtrail_logger / node_modules / jsprim / lib / jsprim.js View on Github external
function validateJsonObjectJS(schema, input)
{
	var report = mod_jsonschema.validate(input, schema);

	if (report.errors.length === 0)
		return (null);

	/* Currently, we only do anything useful with the first error. */
	var error = report.errors[0];

	/* The failed property is given by a URI with an irrelevant prefix. */
	var propname = error['property'];
	var reason = error['message'].toLowerCase();
	var i, j;

	/*
	 * There's at least one case where the property error message is
	 * confusing at best.  We work around this here.
	 */
github joyent / node-jsprim / lib / jsprim.js View on Github external
function validateJsonObjectJS(schema, input)
{
	var report = mod_jsonschema.validate(input, schema);

	if (report.errors.length === 0)
		return (null);

	/* Currently, we only do anything useful with the first error. */
	var error = report.errors[0];

	/* The failed property is given by a URI with an irrelevant prefix. */
	var propname = error['property'];
	var reason = error['message'].toLowerCase();
	var i, j;

	/*
	 * There's at least one case where the property error message is
	 * confusing at best.  We work around this here.
	 */
github persvr / pintura / lib / facet.js View on Github external
value: function(id){
							if(facetPrototype.save){
								facetPrototype.save.call(this, source);
							}
							var validation = validate(this, facetSchema);
							var instance = this;
							for(var i in this){
								if(this.hasOwnProperty(i)){
									transfer(this[i]);
								}
							}
							for (var i in source){
								if(source.hasOwnProperty(i) && !this.hasOwnProperty(i)){
									transfer(undefined);
								}
							}
							mustBeValid(validation);
							if(transaction){
								var newIndex = transaction.newInstances && transaction.newInstances.indexOf(instance);
							} 
							try{
github mlegenhausen / node-ogone-directlink / lib / ogone.js View on Github external
properties: {
            pspid: {
                type: 'string',
                required: true
            },
            pswd: {
                type: 'string',
                required: true
            },
            userid: {
                type: 'string',
                required: true
            }
        }
    }, true);
    var result = JSONSchema.validate(json, schema);
    if (!result.valid) throw new Error(result.errors);
    this.query = Object.clone(json) || {};
    this.url = url;
    this.parser = new xml2js.Parser(xml2js.defaults['0.1']);
}