maybe_as_enum
No overview available.
def maybe_as_enum(
value: Any,
enum_type: Type[Enum]
) - > Any
Converts a raw value into a member of a specified Enum class if possible, otherwise returns the original value.
Parameters
| Name | Type | Description |
|---|---|---|
| value | Any | The raw input value to be converted, typically a string or integer representing an enum member. |
| enum_type | Type[Enum] | The Enum class against which the input value is validated and converted. |
Returns
| Type | Description |
|---|---|
Any | The corresponding Enum member if the value is valid for the Enum type, otherwise the original input value. |