-
Notifications
You must be signed in to change notification settings - Fork 11
/
index.js
39 lines (33 loc) · 1.57 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const _ = require('lodash')
const Engine = require('./src/engine.js')
const defaultRules = require('./rules.json')
const rulesCustom = require('./rules-custom.json')
const logger = require('./src/logger.js')('mip-validator:index')
function engineFactory(rules) {
// NPM compliance
if (rules === 'package.json') {
return require('./package.json')
}
var engine = new Engine(rules || defaultRules)
// attr
engine.register(require('./src/validators/disallowed_attr.js'))
engine.register(require('./src/validators/mandatory_oneof_attr_missing.js'))
engine.register(require('./src/validators/invalid_attr_value.js'))
engine.register(require('./src/validators/invalid_property_value_in_attr_value.js'))
engine.register(require('./src/validators/mandatory_attr_or_missing.js'))
// tag
engine.register(require('./src/validators/disallowed_tag.js'))
engine.register(require('./src/validators/duplicate_unique_tag.js'))
engine.register(require('./src/validators/mandatory_tag_missing.js'))
engine.register(require('./src/validators/invalid_inner_html.js'))
engine.register(require('./src/validators/ignore_tag.js'))
// nesting
engine.register(require('./src/validators/disallowed_tag_ancestor.js'))
engine.register(require('./src/validators/mandatory_tag_ancestor.js'))
engine.register(require('./src/validators/mandatory_tag_parent.js'))
return engine
}
// make a separate copy of rules
engineFactory.rules = _.cloneDeep(defaultRules)
engineFactory.rulesCustom = _.cloneDeep(rulesCustom)
module.exports = engineFactory