Skip to content

Commit d833d35

Browse files
committed
Fix CredentialQuery ID nullability
Signed-off-by: Johannes Tuerk <johannes.tuerk@lissi.id>
1 parent 4145b40 commit d833d35

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/WalletFramework.Oid4Vc/Oid4Vp/Dcql/CredentialQueries/CredentialQuery.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,15 @@ public static Validation<CredentialQuery> FromJObject(JObject json)
5858
{
5959
var id = json.GetByKey(IdJsonKey)
6060
.OnSuccess(token => token.ToJValue())
61-
.OnSuccess(value => CredentialQueryId.Create(value.Value?.ToString() ?? string.Empty))
62-
.ToOption();
61+
.OnSuccess(value =>
62+
{
63+
if (string.IsNullOrWhiteSpace(value.Value?.ToString()))
64+
{
65+
return new StringIsNullOrWhitespaceError<CredentialQueryId>();
66+
}
67+
68+
return CredentialQueryId.Create(value.Value.ToString());
69+
});
6370

6471
var format = json.GetByKey(FormatJsonKey)
6572
.OnSuccess(token => token.ToJValue())
@@ -99,13 +106,13 @@ public static Validation<CredentialQuery> FromJObject(JObject json)
99106
}
100107

101108
private static CredentialQuery Create(
102-
Option<CredentialQueryId> id,
109+
CredentialQueryId id,
103110
string format,
104111
CredentialMetaQuery meta,
105112
Option<IEnumerable<ClaimQuery>> claims,
106113
Option<IEnumerable<ClaimSet>> claimSets) => new()
107114
{
108-
Id = id.ToNullable(),
115+
Id = id,
109116
Format = format,
110117
Meta = meta,
111118
Claims = claims.ToNullable()?.ToArray(),

0 commit comments

Comments
 (0)