Skip to main content

parse_boolean_default

Function parse_boolean_default 

Source
pub fn parse_boolean_default(value: &str) -> Result<Option<bool>, ()>
Expand description

Parses a boolean column’s default attribute (an untyped xsd:string in the schema XSD, not xsd:boolean - it has to tolerate whatever a hand-written schema file spells out) into either an explicit default value or, for the null sentinel, an explicit request for no default constraint to be emitted at all (distinct from the attribute being absent, which callers should handle before ever calling this).

Recognizes true/1/yes/on and false/0/no/off, trimmed and case-insensitive. Returns Err(()) for anything else - shared by Schema::validate() (which reports it as a validation error up front) and the SQL generator (which can then treat any value reaching it as already validated, rather than silently guessing).