Conversation
There was a problem hiding this comment.
There are still some leftover println! statements in this file :)
|
|
||
| let errors: Vec<ValidationError> = schema.iter_errors(data).collect(); | ||
| if !errors.is_empty() { | ||
| println!("Validation errors: {errors:#?}"); |
There was a problem hiding this comment.
Can this be removed? Or should this be error! instead?
|
|
||
| #[test] | ||
| fn credential_schema_validation_elm_edc_ok() { | ||
| let result = validate_credential_types(&EXAMPLE_BASIC_ELM_EDC); |
There was a problem hiding this comment.
Here the value that is being passed to validate_credential_types is a Value::Object, however the code introduced here passes a Value::String which will then always result in debug!("No credential type found, skipping validation");.
|
|
||
| // Select correct draft version for JSON Schema Validator | ||
| // Define the relative path to our jsonschema folder needed for the LocalRetriever | ||
| let jsonschema_dir = std::env::current_dir().unwrap().join("resources/jsonschemas"); |
There was a problem hiding this comment.
This will panic on mobile (or in any environment where the application runs without the source code) because resources/* is not part of the binary. I think there are at least two ways to deal with this:
- Take a look at
initialize_storageand how we make use of Tauri'sdata_dirmethod. - Easier option (and therefore probably preferred): since we're dealing with static data here (in contrast to
STATE_FILE,STRONGHOLD, etc.. --> Embed the JSON Values directly in to the code the same way we do for Ferris's test Credentials inferris_static_profile.rs.
There was a problem hiding this comment.
If you go with option 2 I think you should still be able to keep your json files the way they are if you just 'include' them into the code through include_str!.
There was a problem hiding this comment.
took a slightly different approach but i think we are still aligned
| Unknown, | ||
| /// This trait is solely to add a method to serde_json::Value for converting Values to Strings cleanly | ||
| pub trait ValueToString { | ||
| fn to_clean_string(&self) -> Option<String>; |
There was a problem hiding this comment.
Could you add a few unit tests for this function (happy cases and also error cases)? This could help with documenting what this function does and why we need it. I do understand what you mean by "clean string", but maybe we can use a more common term such as "unescaped" or "unquoted" or similar.
Description of change
I've added support for ELM validation in the
validate_credential_types()function.To avoid confusion: the European Publication Office has converted the VC DM 1.1 into a JSON Schema as well but enhanced it to match the EDC with fields such as
validFromandissued, which are not in the original VC DM 1.1.Therefore, we now have 2 distinct VC DM 1.1 JSON Schemas. One is created by ourselves, true to the spec. The other is provided by European Publication Office as it is referenced in their EDC JSON Schema.
Links to any relevant issues
How the change has been tested
The old tests pass.
I've added a unit test for a valid ELM validation.
Run
cargo test --allin the repo root to test.Definition of Done checklist
Add an
xto the boxes that are relevant to your changes.