enum#
- caput.config.enum(options: list[Any], default: Any | None = None) Property[source]#
Property type that accepts only a set of possible values.
- Parameters:
- options
list[Any] List of allowed options.
- defaultAny, optional
The optional default value.
- options
- Returns:
- enum
Property A property instance setup to validate an enum type.
- enum
- Raises:
ValueErrorIf the default value is not part of the options.
Examples
Should be used like:
class Project: mode = enum(["forward", "backward"], default="forward")