Open kamilglod opened 1 year ago
Please post a code example which shows what you're trying to do. How does __iter
help you build a path?
@jprochazk Let's say I have struct like:
pub struct ValidationError {
pub field: Vec<String>,
pub code: String,
}
where field
is a filed like ["top_level", "0", "nested_field1"]
And I want to return vec of those ValudationError's:
pub fn aggregate_errors(validation_errors: &Report) -> Vec<ValidationError> {
let mut flatten_errors: Vec<ValidationError> = Vec::new();
for (path, error) in validation_errors.iter() {
let field = Vec::from_iter(path.__iter().rev().map(|(_kind, val)| val.to_string()));
flatten_errors.push(ValidationError {
code: error.message().to_string(),
field,
});
}
flatten_errors
}
Report
is pretty much the same thing as a Vec<ValidationError>
. What is ValidationError
used for?
It's used to pass it as dict to Python code.
I'm trying to use Path to build field path like
["top_level", "0", "nested_field1"]
, it would be easy when having access toPath.components
but it's private. Can you add a possibility to access path in a different way than.to_string()
? All that needs to be done is to make__iter()
public.