Closed mpsonntag closed 4 years ago
Looks great! Thanks.
One small note: I think the reason I brought up 3-digit status codes in our last meeting was to separate the categories by the first digit, so 1xx
would signify a required attribute value is missing or empty, 2xx
would mean a uniqueness constraint is violated, 4xx
is property related, and so on. The idea was that if we somehow end up with more than 10 rules for a category (e.g., 10 rules for properties) the 2-digit system wouldn't suffice.
That was quick. @jgrewe I'm good to merge.
This PR contains a couple of potentially controversial points and should be discussed here before merging and addresses the issues #377, #378 and #379.
Changes to the Validation class enabling Custom Validation Instances sneaked itself in at an earlier commit and should be taken into account when reviewing this PR. Check changes in
Validation.__init__()
andrun_validation
andregister_custom_handler
methods. Sorry for the mixup...This PR
ValidationError.__repr__
to make it more convenient to read.report
method to theValidation
class to provide a general overview of collected errors and warnings.report
method whenever a Document is saved or loaded via theODMLParser
resulting in awarnings.warn
message:object_name_readable
validation message toName not assigned
to make it clearer to the user that an object name should be set.section_repository_present
validation from the default validation list. Since Sections rarely have repositories set, this validation can get a bit spammy when validating a Document.Fixes:
Section
andProperty
is added: when trying to set thename
attribute toNone
, it now silently sets the name toid
instead, sincename
must not be empty. It would be set toid
on load and can causeAttributeError
exceptions with some methods if its not set.Points for discussion before merging:
save
andload
as it is now or make any changes to it?ODMLParser
,odml.load
andodml.save
, not when using the underlyingXMLParser
for XML orDictParser
for YAML and JSON to keep the validations out of the core parsers. Any different opinions on this point?