Section ยป enforceAllElements

enforceAllElements()
enforceAllElements(enforce)

Set the default for all following queries on this section of whether the presence of elements in the eno input text should be enforced (by default it is not). This can be used to prevent "template decay" - with presence enforcement enabled elements may be empty, but they (at least their declaration) must be there in the eno text and consequently they can not disappear from a template over time without triggering an error.

enocolor: blue
javascriptconst document = eno.parse(input);

document.field('sound');  // returns null

document.enforceAllElements();

document.field('sound');  // throws an error
document.field('sound', { enforceElement: false });  // returns null

Parameters

enforce

An optional boolean indicating whether to enforce or not. (true is the default if left out)