Skip to content

Conversation

@Oran-Dan
Copy link
Contributor

@Oran-Dan Oran-Dan commented Dec 19, 2025

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 validFrom and issued, 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 --all in the repo root to test.

Definition of Done checklist

Add an x to the boxes that are relevant to your changes.

  • I have followed the contribution guidelines for this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@Oran-Dan Oran-Dan self-assigned this Dec 19, 2025
@Oran-Dan Oran-Dan added the Backend This issue pertains to the UniMe backend. label Dec 19, 2025
@Oran-Dan Oran-Dan marked this pull request as ready for review December 19, 2025 13:32
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are still some leftover println! statements in this file :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


let errors: Vec<ValidationError> = schema.iter_errors(data).collect();
if !errors.is_empty() {
println!("Validation errors: {errors:#?}");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be removed? Or should this be error! instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


#[test]
fn credential_schema_validation_elm_edc_ok() {
let result = validate_credential_types(&EXAMPLE_BASIC_ELM_EDC);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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");.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


// 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");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. Take a look at initialize_storage and how we make use of Tauri's data_dir method.
  2. 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 in ferris_static_profile.rs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

took a slightly different approach but i think we are still aligned

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backend This issue pertains to the UniMe backend.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants