Values#
Base Class#
- class valguard.core.TypedValue(value)[source]#
Bases:
ABC,GenericValidate and store a value of a specific Python type.
Subclasses must define _type, indicating the exact type of value accepted. For example, an IntValue subclass would define _type = int.
For type-checked access, use the as_* properties, like as_int and as_bool.
- __str__()[source]#
Return a string representation suitable for writing to a results file.
- Return type:
str
- property as_bool: bool#
- property as_float: float#
- property as_int: int#
- property as_str: str#
- property to_float: float#
Convert value to float if applicable.
- property value: T#
Note
While TypedValue is the base class for all constraint-aware value wrappers,
a generic alias is available for convenience:
Value = TypedValue[Any]
Use Value for type annotations when the specific constraint is either irrelevant or varies across use cases.
For runtime checks, prefer:
isinstance(obj, TypedValue)
Concrete Value Types#
- class valguard.core.FloatValue(value)[source]#
Float value. Formatted to two decimal places for display.
- property as_float: float#