UNPKG

@windingtree/wt-search-api

Version:

NodeJS app that enables quick search over data from Winding Tree platform

18 lines (13 loc) 484 B
const tv4 = require('tv4'); const notificationSchema = require('./notification-schema.json'); class ValidationError extends Error {}; module.exports.ValidationError = ValidationError; function _validate (data, schema) { if (!tv4.validate(data, schema, false, true)) { const msg = tv4.error.message + ': ' + tv4.error.dataPath; throw new ValidationError(msg); } } module.exports.validateNotification = function (data) { return _validate(data, notificationSchema); };