-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: handle rust types #47
base: main
Are you sure you want to change the base?
Conversation
} | ||
} | ||
RustType::Int => { | ||
if key.parse::<i64>().is_err() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSON key should be in string format
test/main.echo
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove echo file
echo-library/src/types/rust_types.rs
Outdated
@@ -1,3 +1,5 @@ | |||
use rayon::collections::btree_map::IterMut; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove unused imports
} | ||
let parsed_value = serde_json::from_str(&value_str)?; | ||
validate_value(&parsed_value, &input_type)?; | ||
// validate_value(&serde_json::from_str(&value_str)?, &input_type)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code clean up
(serde_json::Value::Number(number), value) if number.is_f64() => { | ||
validate_value(value, value_type)? | ||
} | ||
(serde_json::Value::Bool(bool_value), value) => validate_value(value, value_type)?, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validation for tuple types, hashmaps, arrays, and similar structures is not handled.
@@ -1,5 +1,83 @@ | |||
use super::*; | |||
use anyhow::anyhow; | |||
|
|||
fn validate_value(value: &serde_json::Value, expected_type: &RustType) -> anyhow::Result<()> { | |||
match expected_type { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validation for Value type not handled.
Pull Request Template
Description
Handle the rustypes List, Tuple, HashMap, Struct
Please select the options that are relevant.
Checklist: