vcorelib.schemas package#

Submodules#

vcorelib.schemas.base module#

A module defining interfaces for schema enforcement.

class vcorelib.schemas.base.Schema(data: Dict[str, str | int | float | bool | None | Dict[str, str | int | float | bool | None] | List[str | int | float | bool | None]], **_)[source]#

Bases: ABC

A base class for schema enforcement.

classmethod from_path(path: Path | str | None, includes_key: str = None, **kwargs) T[source]#

Load a schema from a data file on disk.

class vcorelib.schemas.base.SchemaMap[source]#

Bases: UserDict, MutableMapping[str, Schema]

A class for managing multiple schema objects.

classmethod from_package(package: str, includes_key: str = None, **kwargs) V[source]#

Create a new JSON-schema map from package data.

abstract classmethod kind() Type[Schema][source]#

Implement this to determine the concrete schema type.

load_directory(path: Path | str | None, includes_key: str = None, **kwargs) Iterator[Tuple[str, Schema]][source]#

Load a directory of schema files into the map.

load_file(path: Path | str | None, includes_key: str = None, **kwargs) Tuple[str, T][source]#

Load a schema file into the map.

load_package(package: str, path: Path | str | None = 'schemas', package_subdir: str = 'data', includes_key: str = None, **kwargs) Iterator[Tuple[str, Schema]][source]#

Load schemas from package data.

exception vcorelib.schemas.base.SchemaValidationError[source]#

Bases: Exception

An exception type for schema errors.

vcorelib.schemas.json module#

A module for interacting with JSON schemas.

class vcorelib.schemas.json.JsonSchema(data: Dict[str, str | int | float | bool | None | Dict[str, str | int | float | bool | None] | List[str | int | float | bool | None]], **_)[source]#

Bases: Schema

An object wrapper for: https://horejsek.github.io/python-fastjsonschema/.

See also: https://json-schema.org/.

class vcorelib.schemas.json.JsonSchemaMap[source]#

Bases: SchemaMap

A class for managing multiple schema objects.

classmethod kind() Type[JsonSchema][source]#

Implement this to determine the concrete schema type.

vcorelib.schemas.json.package_handler(uri: str) Dict[str, str | int | float | bool | None | Dict[str, str | int | float | bool | None] | List[str | int | float | bool | None]][source]#

Load data from a package.

vcorelib.schemas.mixins module#

A module for implementing schema-validated classes.

class vcorelib.schemas.mixins.SchemaMixin(schemas: SchemaMap, valid_attr: str = 'data')[source]#

Bases: object

A class that allows inheriting classes to validate an attribute with a schema.

schema: Schema#
classmethod schema_name() str[source]#

A default name for this class’s schema.

validate(valid_attr: str = 'data') None[source]#

Validate an instance attribute based on this instance’s schema.

Module contents#

A module for working with various schema enforcement implementations.

class vcorelib.schemas.CerberusSchema(data: Dict[str, str | int | float | bool | None | Dict[str, str | int | float | bool | None] | List[str | int | float | bool | None]], **kwargs)[source]#

Bases: Schema

An object wrapper for: https://docs.python-cerberus.org/en/stable/.

class vcorelib.schemas.CerberusSchemaMap[source]#

Bases: SchemaMap

A class for managing multiple schema objects.

classmethod kind() Type[CerberusSchema][source]#

Implement this to determine the concrete schema type.