runique 3.0.2

A Django-inspired web framework for Rust with ORM, templates, and comprehensive security middleware
Documentation
1
2
3
4
5
6
7
8
9
10
use crate::utils::aliases::StrMap;

/// Reads `key` from submitted form data and interprets it as a checkbox-style
/// boolean: `"on"`, `"true"` or `"1"` is `true`, anything else (including the
/// key being absent, as an unchecked HTML checkbox omits itself) is `false`.
pub fn parse_bool(data: &StrMap, key: &str) -> bool {
    data.get(key)
        .map(|v| v == "on" || v == "true" || v == "1")
        .unwrap_or(false)
}