TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/alex-ber/AlexBerUtils/llms.txt
Use this file to discover all available pages before exploring further.
models module provides utilities for working with enums, sequential integer generation, JSON/list validation, and field checking — useful for building Pydantic models, dataclasses, and other structured data types.
Auto
A callable counter that generates sequential integers starting from a configurable value. Designed to be used with Python’sEnum to automatically assign sequential integer values to enum members.
Usage with Enum
The first integer value returned on the first call. Subsequent calls increment by 1.
int on each call.
create_auto
Factory function that creates a newAuto instance.
Starting value for the counter.
Auto instance.
parse_json
Parses a JSON string or passes through a list directly. Useful when a field can be supplied as either a JSON-encoded list or a native Python list.The value to parse. Must be a JSON string encoding a list, or an already-constructed list.
Name of the field being parsed, used in error messages.
List[Any] — the parsed or passed-through list.
Raises:
ValueError— ifjson_disNone, if the JSON string does not parse to a list, or ifjson_dis neither a string nor a list.
validate_same_length
Asserts that all provided iterables have the same length.The iterables to compare. All must support
len().Comma-separated field names used in the error message. Must be provided.
None
Raises:
ValueError— iffield_namesis not provided, or if the iterables have different lengths.
Returns immediately (without error) if all arguments are empty iterables.
check_not_empty
Validates that a value is not falsy. RaisesValueError if it is.
The value to check.
An object with a
field_name attribute used in the error message.v unchanged if it is truthy.
Raises:
ValueError— ifvis falsy (None,"",0,[], etc.).
convert_value_to_enum
Converts an integer, string, or existing enum instance to an enum member.The value to convert. Integers are matched against enum values. Strings are matched against enum names. Existing enum instances are returned as-is.
The target enum class.
enum_class.
Raises:
ValueError— if the value cannot be mapped to any member ofenum_class.
enum_field_validator
Returns a Pydantic-compatible validator function that converts a list of raw values to a list of enum members.The Pydantic field object (carries
field_name for error messages).The enum class to convert values to.
(v: Any) -> List[Enum].
Raises:
ValueError— if the input is not a list, or if any element cannot be converted.
