MCPcopy
hub / github.com/CacheControl/json-rules-engine / render

Function render

examples/09-rule-results.js:42–60  ·  view source on GitHub ↗
(message, ruleResult)

Source from the content-addressed store, hash-verified

40 })
41
42 function render (message, ruleResult) {
43 // if rule succeeded, render success message
44 if (ruleResult.result) {
45 return console.log(`${message}`.green)
46 }
47 // if rule failed, iterate over each failed condition to determine why the student didn't qualify for athletics honor roll
48 const detail = ruleResult.conditions.all.filter(condition => !condition.result)
49 .map(condition => {
50 switch (condition.operator) {
51 case 'equal':
52 return `was not an ${condition.fact}`
53 case 'greaterThanInclusive':
54 return `${condition.fact} of ${condition.factResult} was too low`
55 default:
56 return ''
57 }
58 }).join(' and ')
59 console.log(`${message} ${detail}`.red)
60 }
61
62 /**
63 * On success, retrieve the student's username and print rule name for display purposes, and render

Callers 1

startFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…