How to use the getSchema function from tv4

Find comprehensive JavaScript tv4.getSchema code examples handpicked from public code repositorys.

146
147
148
149
150
151
152
153
154
Return a schema from the cache.

* `uri` the uri of the schema (may contain a `#` fragment)

````js
var schema = tv4.getSchema('http://example.com/schema');
````

##### getSchemaMap()
fork icon190
star icon0
watch icon34

+ 3 other calls in file

140
141
142
143
144
145
146
147
148
149
function loadSchema(schema, callback) {
  return Promise.resolve()
    .then(() => {
      const tld = !isString(schema) || schema.indexOf('localhost') === -1;
      if (isString(schema) && validatorJS.isURL(schema, { require_tld: tld })) {
        const cachedSchema = tv4.getSchema(schema);
        if (cachedSchema) {
          return cachedSchema;
        }
        return makeRequest(schema)
fork icon0
star icon2
watch icon8

+ 11 other calls in file

43
44
45
46
47
48
49
50
51
52

if (typeof schema === 'string') {
  var uri = schema;
  baseUri = baseUri || 'http://schema.ninjablocks.com/';
  var resolvedUri = tv4.resolveUrl(baseUri, uri);
  schema = tv4.getSchema(resolvedUri);
  if (!schema) {
    throw new Error('Failed to resolve schema $ref. ' + (urlHistory? Object.keys(urlHistory).join(', ') : uri));
  }
}
fork icon6
star icon2
watch icon14

4
5
6
7
8
9
10
11
12
    addSchema: function (uri, schema) {
        return TV4.addSchema(uri, schema);
    },

    getSchema: function (uri) {
        return TV4.getSchema(uri);
    }

};
fork icon1
star icon4
watch icon3

12
13
14
15
16
17
18
19
20
21
function validationErrorToString(e) {
  return (e.dataPath) ? e.dataPath + " -- " + e.message : e.message;
}

exports.validateJsonSyntax = function (json, schemaUri) {
  var schema = tv4.getSchema(schemaUri);
  var ret = tv4.validateMultiple(json, schema, true);
  return {
    valid: ret.valid,
    errors: _.map(ret.errors, validationErrorToString),
fork icon0
star icon2
watch icon9

+ 3 other calls in file

21
22
23
24
25
26
27
28
29
tv4.addSchema(capitalizedSchema, schemas[key]);

function Model (doc) {
  Base.call(this, doc);
  this.me = capitalized;
  this.schema = tv4.getSchema(capitalizedSchema);
};
Model.prototype.__proto__ = Base.prototype;
//inherits(Model, Base);
fork icon0
star icon0
watch icon0