Skip to main content

optional_bool

Function optional_bool 

Source
pub fn optional_bool(
    input: &Value,
    field: &str,
    default: bool,
) -> Result<bool, ToolError>
Expand description

Helper to extract an optional bool field with default.

A wrong type is an error, never a silent fall back to default. In particular the string "true" is refused rather than coerced: the default this used to fall back to is frequently the opposite of what the caller asked for, and some of those defaults gate irreversible actions.