a zip code crypto-currency system good for red ONLY

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. 'use strict';
  2. var ruleModules = require('./_rules')
  3. , toHash = require('./util').toHash;
  4. module.exports = function rules() {
  5. var RULES = [
  6. { type: 'number',
  7. rules: [ { 'maximum': ['exclusiveMaximum'] },
  8. { 'minimum': ['exclusiveMinimum'] }, 'multipleOf', 'format'] },
  9. { type: 'string',
  10. rules: [ 'maxLength', 'minLength', 'pattern', 'format' ] },
  11. { type: 'array',
  12. rules: [ 'maxItems', 'minItems', 'uniqueItems', 'contains', 'items' ] },
  13. { type: 'object',
  14. rules: [ 'maxProperties', 'minProperties', 'required', 'dependencies', 'propertyNames',
  15. { 'properties': ['additionalProperties', 'patternProperties'] } ] },
  16. { rules: [ '$ref', 'const', 'enum', 'not', 'anyOf', 'oneOf', 'allOf' ] }
  17. ];
  18. var ALL = [ 'type' ];
  19. var KEYWORDS = [
  20. 'additionalItems', '$schema', '$id', 'id', 'title',
  21. 'description', 'default', 'definitions'
  22. ];
  23. var TYPES = [ 'number', 'integer', 'string', 'array', 'object', 'boolean', 'null' ];
  24. RULES.all = toHash(ALL);
  25. RULES.types = toHash(TYPES);
  26. RULES.forEach(function (group) {
  27. group.rules = group.rules.map(function (keyword) {
  28. var implKeywords;
  29. if (typeof keyword == 'object') {
  30. var key = Object.keys(keyword)[0];
  31. implKeywords = keyword[key];
  32. keyword = key;
  33. implKeywords.forEach(function (k) {
  34. ALL.push(k);
  35. RULES.all[k] = true;
  36. });
  37. }
  38. ALL.push(keyword);
  39. var rule = RULES.all[keyword] = {
  40. keyword: keyword,
  41. code: ruleModules[keyword],
  42. implements: implKeywords
  43. };
  44. return rule;
  45. });
  46. if (group.type) RULES.types[group.type] = group;
  47. });
  48. RULES.keywords = toHash(ALL.concat(KEYWORDS));
  49. RULES.custom = {};
  50. return RULES;
  51. };