Requiring all elements

Often we want to ensure that eno documents authored by users always contain all of the fields that can be specified according to our schema, regardless of whether they are actually used or left empty, because the simple fact that they see the field in the document they are authoring informs them that it exists and can be used, whereas if it were entirely missing in the document, only external documentation can point the user to the possiblity to define that specific field.

To easily enable such behavior there is a shortcut that saves us from writing out required in front of every element we query from the document:


Here the field name always has to be present, no matter if it's empty or not.

Note that this can be called not only on the document but also on any section or fieldset:

details = document.section('details')


Any element queries on details from that point on always require the elements to be there, including the ones in subsections and fieldsets, recursively.

Lastly, this setting can also be reverted again by explicitly passing False:


Here the field name is optional, just as its value.

Next page: Touching elements