Skip to content
This repository has been archived by the owner on Nov 17, 2022. It is now read-only.

Improve help text for validation error err-not-iati-xml-missing-required-element #250

Open
dalepotter opened this issue Nov 22, 2017 · 1 comment
Labels
enhancement Some sort of new functionality (rather than fixing or tweaking something that already existed). error-handling Relating to error handling. validation Changes to validation functionality.

Comments

@dalepotter
Copy link
Contributor

dalepotter commented Nov 22, 2017

In our work to use pyIATI in the test runner for the v2.03 IATI schema work, we test that failing files fail for an expected reason.

The failing file here tests that an non-permitted child element fails schema validation. This creates the following iati.validator.ValidationError object:

(Pdb) error_log = iati.validator.validate_is_iati_xml(dataset, activity_schema)
(Pdb) len(error_log)
1
(Pdb) error_log[0]
<iati.validator.ValidationError object at 0x1044c8048>
(Pdb) error_log[0].name
'err-not-iati-xml-missing-required-element'
(Pdb) error_log[0].info
"<string>:26:0:ERROR:SCHEMASV:SCHEMAV_ELEMENT_CONTENT: Element 'unexpected-element': This element is not expected. Expected is ( ##other* )."
(Pdb) error_log[0].name
'err-not-iati-xml-missing-required-element'
(Pdb) error_log[0].help
'There are a number of mandatory elements that an IATI data file must contain. Additionally, these must occur in the required order.\nFor more information about what an XML element is, see https://www.w3schools.com/xml/xml_elements.asp'

The generated error err-not-iati-xml-missing-required-element seems unintuitive given that the info attribute states Element 'unexpected-element': This element is not expected. Expected is ( ##other* )..

Is ti worth adding a new mapping to this to generate a new error, for example err-not-iati-xml-unexpected-element ?

@dalepotter dalepotter added enhancement Some sort of new functionality (rather than fixing or tweaking something that already existed). error-handling Relating to error handling. validation Changes to validation functionality. labels Nov 22, 2017
@hayfield
Copy link
Contributor

err-not-iati-xml-missing-required-element is created based on the lxml error SCHEMAV_ELEMENT_CONTENT.

The current test for this error related only to missing elements. I would expect that mis-ordered elements will also cause this error, though it is not tested - this seems to be something that should be added.

The description and help attributes should provide useful information, with info being there for completeness sake. This may feed into #231.

@hayfield hayfield added the question A question. label Nov 22, 2017
@hayfield hayfield changed the title Add new lxml error mapping for unexpected elements Improve help text for validation error err-not-iati-xml-missing-required-element Nov 22, 2017
@hayfield hayfield removed the question A question. label Nov 22, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Some sort of new functionality (rather than fixing or tweaking something that already existed). error-handling Relating to error handling. validation Changes to validation functionality.
Projects
None yet
Development

No branches or pull requests

2 participants