Fieldset ยป assert_all_touched
assert_all_touched
assert_all_touched(options)
assert_all_touched(message, options)
assert_all_touched(message_function, options)
Assert that all entries of this fieldset that were present in the parsed eno document were also queried (and therefore touched) by the application. This, combined with eno's query methods, serves to ensure a two-way guarantee for both users and developers: No data that the application requires can be left out, and no data that the application does not process can be supplied.
enoImportant data:
A = I need to be processed!
B = Me too!
python>>> document = enopy.parse(input)
>>> fieldset = document.fieldset('Important data')
>>> data_a = fieldset.entry('A')
# ... processing happens only for data_a
>>> fieldset.assert_all_touched()
ValidationError: An excess element named 'B' was found, is it possibly a typo?
>>> fieldset.assert_all_touched(only=['A']) # passes
>>> fieldset.assert_all_touched(skip=['B']) # passes
>>> custom_message = lambda name, value: f"{name} is not supported by the application, please contact support if you think it should be"
>>> fieldset.assert_all_touched(custom_message)
ValidationError: B is not supported by the application, please contact support if you think it should be
Parameters
message or message_functionOptional, usually the default message (An excess element named [NAME] was
found, is it possibly a typo?) will do fine. If you want to override it,
provide either a static message as a string, or alternatively a function
returning a string. (name
and value
are provided as arguments)
only
A list of strings, e.g. ['name', 'email']
, which specifies to only check these elements for whether they've been touched.
skip
A list of strings, e.g. ['phone number']
, which specifies to exclude these elements from checking whether they've been touched.