vibe.handlers.tristate¶
Handler for Tristate Input Data Types.
Implements the DataTypeHandler interface for tristate (yes/no/don't know) inputs. Handles widget rendering, form data processing, and runtime validation for three-state boolean fields where "don't know" or "not applicable" is a valid answer.
TristateHandler ¶
Handler for tristate (yes/no/don't know) radio button input.
__init__ ¶
__init__(definition: dict[str, Any]) -> None
Initialize and track whether a default value was explicitly configured.
render_widget ¶
render_widget(name: str, current_value: bool | None, error_message: str | None = None) -> str
Render radio-button widget for tristate choices.
get_additional_widget_context ¶
get_additional_widget_context(name: str, current_value: bool | None, error_message: str | None = None) -> dict[str, Any]
Provide widget option labels and current value.
Returns three options: yes (True), no (False), and dontknow (None). The third option label is customizable via the 'none_label' definition parameter.
process_form_data ¶
process_form_data(name: str, form_data: MultiDictLike) -> bool | None
Parse yes/no/dontknow form values to True/False/None.
Accepts case-insensitive values: - "yes", "true", "1" -> True - "no", "false", "0" -> False - "dontknow", "maybe" -> None - "" (empty/not submitted) -> None
validate_input ¶
Validate tristate input.
For tristate fields, all three values (True, False, None) are valid answers that satisfy required=true. The base class validate_input treats None as empty, but for tristate, None means "don't know" which is a valid answer.
Therefore, we always return None (no error) for tristate fields.
get_preview_placeholder_value ¶
get_preview_placeholder_value() -> None
Return preview placeholder; keep falsy to avoid probing side-effects.