obsplus.utils.validate module

Core modules for validate.

obsplus.utils.validate.decompose(obj)[source]

Decompose an object into a dict of {class: [instance1, instance2, …]}.

Parameters:

obj – The object to decompose.

Return type:

A dict of class definitions (keys) and lists of instances (values).

obsplus.utils.validate.decomposer(cls)[source]

Register a function as a decomposer for a given class.

The decomposer simply splits the object into its constitutive parts that may need to be tested. It should return a dict of the following form:

{cls: [instance1, instance2, …], … }

Parameters:

cls – The class the registered decomposer is to act on. Can be a tuple of classes.

obsplus.utils.validate.validate(obj, namespace, report=False, **kwargs)[source]

Validate an object using validators in specified namespace.

Parameters:
  • obj – Any function whose type has registered validators.

  • namespace (str) – The validation namespace specified by validators.

  • report (bool) – If True, return a dataframe which passed/failed validators and objects and suppress all failures.

Return type:

Optional[DataFrame]

Notes

Parameters can be passed individual validators using kwargs.

obsplus.utils.validate.validator(namespace, cls)[source]

Register a callable to a given namespace to operate on type cls.

Parameters:
  • namespace (str) –

  • cls (type) –