Skip to content

Commit

Permalink
fix: building of W3C credential values passed through the FFI (#323)
Browse files Browse the repository at this point in the history
Signed-off-by: artem.ivanov <artem.ivanov@dsr-corporation.com>
  • Loading branch information
Artemkaaas committed Feb 7, 2024
1 parent c12eb3c commit 9481ae0
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/services/w3c/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@ pub struct MakeCredentialAttributes(pub(crate) CredentialSubject);

impl MakeCredentialAttributes {
pub fn add(&mut self, name: impl Into<String>, raw: impl Into<String>) {
self.0
.0
.insert(name.into(), CredentialAttributeValue::String(raw.into()));
let string_value = raw.into();
let value = if let Ok(number) = string_value.parse::<i32>() {
CredentialAttributeValue::Number(number)
} else {
CredentialAttributeValue::String(string_value)
};

self.0 .0.insert(name.into(), value);
}
}

Expand Down

0 comments on commit 9481ae0

Please sign in to comment.