validate(self, validator, preserve_errors=False, copy=False, section=None)
It uses the validator
object from validate.py.
To run validate
on the current ConfigObj, call: :
test = config.validate(validator)
(Normally having previously passed in the configspec when the ConfigObj was created - you can dynamically assign a dictionary of checks to the configspec
attribute of a section though).
It returns True
if everything passes, or a dictionary of pass/fails (True/False). If every member of a subsection passes, it will just have the value True
. (It also returns False
if all members fail).
In addition, it converts the values from strings to their native types if their checks pass (and stringify
is set).
If preserve_errors
is True
( False
is default) then instead of a marking a fail with a False
, it will preserve the actual exception object. This can contain info about the reason for failure. For example the VdtValueTooSmallError
indicates that the value supplied was too small. If a value (or section) is missing it will still be marked as False
.
You must have the validate module to use preserve_errors=True
.
You can then use the flatten_errors
function to turn your nested results dictionary into a flattened list of failures - useful for displaying meaningful error messages.
Test the ConfigObj against a configspec.
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them