Skip to content

Commit

Permalink
If env value is true or false parse as bool
Browse files Browse the repository at this point in the history
  • Loading branch information
johnb8 committed Mar 17, 2021
1 parent b4052be commit 4c5cc21
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/env.rs
Expand Up @@ -119,7 +119,13 @@ impl Source for Environment {
let value = if self.try_parsing {
let string_value = Value::new(Some(&uri), ValueKind::String(value.clone()));

if let Ok(parsed) = string_value.clone().into_int() {
// if the value is "true" or "false" it should be parsed as a bool
if let (true, Ok(parsed)) = (
value.to_lowercase() == "true" || value.to_lowercase() == "false",
string_value.clone().into_bool(),
) {
ValueKind::Boolean(parsed)
} else if let Ok(parsed) = string_value.clone().into_int() {
ValueKind::Integer(parsed)
} else if let Ok(parsed) = string_value.clone().into_float() {
ValueKind::Float(parsed)
Expand Down

0 comments on commit 4c5cc21

Please sign in to comment.