Validation Utilities partis.pyproj.validate#
- exception ValidationWarning[source]#
Bases:
RuntimeWarning
- exception ValidationError(msg, doc_root=None, doc_file=None, doc_path=None)[source]#
Bases:
ValueErrorGeneral validation error
- Parameters:
msg (str) – Error message
- exception RequiredValueError(msg, doc_root=None, doc_file=None, doc_path=None)[source]#
Bases:
ValidationError
- exception ValidDefinitionError(msg, doc_root=None, doc_file=None, doc_path=None)[source]#
Bases:
ValidationError
- exception ValidPathError(msg, doc_root=None, doc_file=None, doc_path=None)[source]#
Bases:
ValidationErrorFile is not valid
- exception FileOutsideRootError(msg, doc_root=None, doc_file=None, doc_path=None)[source]#
Bases:
ValidPathErrorFile path is outside a desired root directory
- class validating(key=None, root=None, file=None)[source]#
Bases:
objectContext manager to append information to a ValidationError as it propagates
Intermediate frames for internal validating routines, except for the first and last frame, are filtered out of any tracebacks.
- Parameters:
See also
ValidationError
- valid_keys(obj, key_valid=None, value_valid=None, item_valid=None, allow_keys=None, require_keys=None, min_keys=None, wedge_keys=None, mutex_keys=None, deprecate_keys=None, forbid_keys=None, default=None, proxy_keys=None)[source]#
Check that a mapping does not contain un-expected keys
- Parameters:
obj¶ (Mapping) – Mapping object to validate
key_valid¶ (None | callable) – Validates all keys
value_valid¶ (None | callable) – Validates all values
item_valid¶ (None | callable) – Validates all (key,value) pairs
allow_keys¶ (None | list[str]) – Mapping may not contain keys that are not listed.
require_keys¶ (None | list[str]) – Mapping must contain all listed keys.
min_keys¶ (None | list[ list[str] ]) – Mapping must contain at least one key from each list.
wedge_keys¶ (None | list[ list[str] ]) – Mapping must contain either none or all of the listed keys.
mutex_keys¶ (None | list[ list[str] ]) – Mapping may contain at most one key from each list.
deprecate_keys¶ (None | list[ (str, None | str | Required) ]) – First key is marked as deprecated and removed from the Mapping. If new key is given, the value is remapped to the new key. If new key is Required, an error is raised, otherwise a deprecation warning is reported.
forbid_keys¶ (None | list[str]) – Mapping must not contain any of the listed keys.
default¶ (None | Mapping[object, object | type | Validator]) – Default value or validator for given keys.
- class valid_dict(*args, **kwargs)[source]#
Bases:
MappingValidated Mapping
- _proxy_key#
If initialized with a value that is not a Mapping, this key is assigned the value before performing validation.
- Type:
None | str
- _key_valid#
Validates all keys
- Type:
None | callable
- _value_valid#
Validates all values
- Type:
None | callable
- _item_valid#
Validates all (key,value) pairs
- Type:
None | callable
- _wedge_keys#
Mapping must contain either none or all of the listed keys.
- _deprecate_keys#
First key is marked as deprecated and removed from the Mapping. If new key is given, the value is remapped to the new key. If new key is Required, an error is raised, otherwise a deprecation warning is reported.
- _default#
Default value or validator for given keys.
- _validator#
General validator for entire Mapping after above constraints are satisfied.
- Type:
None | Validator
See also