Front end of the Slack clone application.

12345678910111213141516171819202122
  1. 'use strict';
  2. module.exports = function defFunc(ajv) {
  3. if (!ajv.RULES.keywords.switch) require('./switch')(ajv);
  4. defFunc.definition = {
  5. macro: function (schema, parentSchema) {
  6. if (parentSchema.then === undefined)
  7. throw new Error('keyword "then" is absent');
  8. var cases = [ { 'if': schema, 'then': parentSchema.then } ];
  9. if (parentSchema.else !== undefined)
  10. cases[1] = { 'then': parentSchema.else };
  11. return { switch: cases };
  12. }
  13. };
  14. ajv.addKeyword('if', defFunc.definition);
  15. ajv.addKeyword('then');
  16. ajv.addKeyword('else');
  17. return ajv;
  18. };