Skip to content

Commit

Permalink
fix: properly parsing numbers that are strings
Browse files Browse the repository at this point in the history
  • Loading branch information
Datron committed Nov 19, 2024
1 parent c155bb0 commit 0d0e404
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 10 additions & 1 deletion crates/frontend/src/components/context_form/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::{
},
};
use anyhow::Result;
use leptos::logging;
use serde_json::{json, Map, Value};

pub fn get_condition_schema(
Expand Down Expand Up @@ -186,7 +187,15 @@ pub fn construct_context(
} else {
let condition_schemas = conditions
.iter()
.map(|condition| get_condition_schema(condition, dimensions.clone()).unwrap())
.map(
|condition| match get_condition_schema(condition, dimensions.clone()) {
Ok(ans) => ans,
Err(err) => {
logging::log!("Error while getting condition schema {:?}", err);
Value::Null
}
},
)
.collect::<Vec<Value>>();

if condition_schemas.len() == 1 {
Expand Down
2 changes: 2 additions & 0 deletions crates/frontend/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ pub fn parse_value(val: &Value, config_type: ConfigValueType) -> Result<Value, S

ConfigValueType::String => match val {
Value::String(_) => Ok(val.clone()),
Value::Number(i) => Ok(Value::String(i.to_string())),
Value::Bool(b) => Ok(Value::String(b.to_string())),
Value::Array(arr) => {
if arr.iter().all(|item| item.is_string()) {
Ok(val.clone())
Expand Down

0 comments on commit 0d0e404

Please sign in to comment.