pass jsonschema validator as a generic argument
I want to have a generic function which validates all the json files/data against its corresponding schema validators(both runtime and compile time validators). But it looks like the validators doesn't implement any trait because of which I'm not able to pass jsonschema validator to the generic function. main.rs #[jsonschema::validator(schema = r#"{"maxLength": 5}"#)] struct Short; #[jsonschema::validator(schema = r#"{"maxLength": 10}"#)] struct Long; fn validate_with<V: jsonschema::Validator>(validator: &V, instance: &serde_json::Value) -> bool { validator.is_valid(instance) } fn main() { let
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.