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
11
12
13
14
15
16
17
18
//! `BoolChoice` — validation option for boolean fields (expected value true/false/any).
use serde::{Deserialize, Serialize};

/// A boolean validation flag (e.g. "is this field required?") paired with an
/// optional custom error message shown when the check fails.
#[derive(Serialize, Deserialize, Clone, Debug, Default)]
pub struct BoolChoice {
    pub choice: bool,
    pub message: Option<String>,
}

impl BoolChoice {
    /// Creates a flag with the given `choice` and an optional message
    /// overriding the default error text.
    pub fn new(choice: bool, message: Option<String>) -> Self {
        Self { choice, message }
    }
}