12345678910111213141516171819202122232425262728293031323334353637383940 |
- 'use strict';
- var ruleModules = require('./_rules')
- , toHash = require('./util').toHash;
- module.exports = function rules() {
- var RULES = [
- { type: 'number',
- rules: [ 'maximum', 'minimum', 'multipleOf'] },
- { type: 'string',
- rules: [ 'maxLength', 'minLength', 'pattern', 'format' ] },
- { type: 'array',
- rules: [ 'maxItems', 'minItems', 'uniqueItems', 'items' ] },
- { type: 'object',
- rules: [ 'maxProperties', 'minProperties', 'required', 'dependencies', 'properties' ] },
- { rules: [ '$ref', 'enum', 'not', 'anyOf', 'oneOf', 'allOf' ] }
- ];
- var ALL = [ 'type', 'additionalProperties', 'patternProperties' ];
- var KEYWORDS = [ 'additionalItems', '$schema', 'id', 'title', 'description', 'default' ];
- var TYPES = [ 'number', 'integer', 'string', 'array', 'object', 'boolean', 'null' ];
- RULES.all = toHash(ALL);
- RULES.forEach(function (group) {
- group.rules = group.rules.map(function (keyword) {
- ALL.push(keyword);
- var rule = RULES.all[keyword] = {
- keyword: keyword,
- code: ruleModules[keyword]
- };
- return rule;
- });
- });
- RULES.keywords = toHash(ALL.concat(KEYWORDS));
- RULES.types = toHash(TYPES);
- RULES.custom = {};
- return RULES;
- };
|