MCPcopy
hub / github.com/SparkPost/heml / validate

Function validate

packages/heml-validate/src/index.js:11–35  ·  view source on GitHub ↗
($, options = {})

Source from the content-addressed store, hash-verified

9* @return {Array[HEMLError]} an array of heml errors
10*/
11export default function validate ($, options = {}) {
12 const {
13 elements = []
14 } = options
15
16 let errors = []
17
18 for (let element of elements) {
19 const matchedValidators = validators.filter((validator) => validator.name in element)
20
21 if (matchedValidators.length === 0) { return }
22
23 const $nodes = $.findNodes(element.tagName)
24
25 $nodes.forEach(($node) => matchedValidators.forEach((validator) => {
26 try {
27 validator($node, element, $)
28 } catch (e) {
29 errors.push(e)
30 }
31 }))
32 }
33
34 return errors
35}

Callers 1

hemlFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected