How to use the addSchema function from tv4
Find comprehensive JavaScript tv4.addSchema code examples handpicked from public code repositorys.
48 49 50 51 52 53 54 55 56 57
*/ const getImplicitLegacySchemaVersion = (jsonSchema) => { const [schemaVersion] = [['draftV4', metaSchemaV4]].find( ([_, metaSchema]) => { tv4.reset(); tv4.addSchema('', metaSchema); tv4.addSchema(metaSchema.$schema, metaSchema); const validationResult = tv4.validateResult(jsonSchema, metaSchema); return validationResult.valid; }
22
94
16
+ 11 other calls in file
17 18 19 20 21 22 23 24 25 26
let schemas = fs.readdirSync(path.join(__dirname, schemaPath)); schemas = schemas.filter((s) => s.indexOf('.json') !== -1); before(() => { const metaSchema = loadSchema(path.join(__dirname, 'json-schema.json')); tv4.addSchema('http://json-schema.org/draft-04/schema', metaSchema); }); after(() => { tv4.reset(); });
4
32
4
+ 3 other calls in file
GitHub: CARLI/select
34 35 36 37 38 39 40 41 42 43
VendorStatus: require('../schemas/VendorStatus.json') }; function _loadSchemas() { for (var schemaName in schemas) { tv4.addSchema(schemaName + '.json', schemas[schemaName]); } } function listValidTypes() {
0
5
8
0 1 2 3 4 5 6 7 8 9
var TV4 = require('tv4'); module.exports = { addSchema: function (uri, schema) { return TV4.addSchema(uri, schema); }, getSchema: function (uri) { return TV4.getSchema(uri);
1
4
3
105 106 107 108 109 110 111 112 113 114
exports.loadMetaschemaSync(default_metaschemaUri, default_metaschemaPath); if (!exports.metaschema) throw new Error('METASCHEMA not set!'); }; exports.addSchemaName = function(schema, name) { tv4.addSchema(name, schema); }; exports.addSchemaNameFromDir = function(dir, name, cb) { /*
16
3
22
+ 3 other calls in file
4 5 6 7 8 9 10 11 12 13
var tv4 = require('tv4'); //------------------------------------------------------------------------- exports.addJsonSchema = function (uri, schema) { tv4.addSchema(uri, schema); }; function validationErrorToString(e) { return (e.dataPath) ? e.dataPath + " -- " + e.message : e.message;
0
2
9
+ 3 other calls in file
24 25 26 27 28 29 30 31 32
* @param {string} [url] URL/ID of the schema. Can be omitted if schema contains id property * @param {object} schema JSON Schema to add */ function preload(url, schema) { if (schema) { return tv4.addSchema(url, schema); } return tv4.addSchema(url); }
0
2
8
+ 29 other calls in file
26 27 28 29 30 31 32 33 34 35
if (err) { console.log(err); } else { for (var id in refs) { // register resolved refs tv4.addSchema(id, refs[id]); } // validates the first passed schema console.log(tv4.validateResult(data, schemas[0]));
3
0
2
+ 3 other calls in file
GitHub: gabrielmancini/ecwm
16 17 18 19 20 21 22 23 24 25
Object.keys(schemas) .map(function (key) { var capitalized = S(key).capitalize().s; var capitalizedSchema = capitalized + 'Schema' //Add Schema tv4.addSchema(capitalizedSchema, schemas[key]); function Model (doc) { Base.call(this, doc); this.me = capitalized;
0
0
0
tv4.validate is the most popular function in tv4 (982 examples)