Skip to content

Commit

Permalink
refactor: remove check credentialStatus id in vc v2
Browse files Browse the repository at this point in the history
  • Loading branch information
ldhyen99 committed May 10, 2024
1 parent 345624c commit bfad762
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,17 @@ function _checkCredential({
}

if(helpers.hasV1CredentialContext({credential})) {
if('credentialStatus' in credential) {
const {credentialStatus} = credential;
if (
Array.isArray(credentialStatus)
? credentialStatus.some((cs) => !cs.id)
: !credentialStatus.id
) {
throw new Error('"credentialStatus" must include an id.');
}
}

// check issuanceDate cardinality
if(jsonld.getValues(credential, 'issuanceDate').length > 1) {
throw new Error('"issuanceDate" property can only have one value.');
Expand Down Expand Up @@ -742,13 +753,6 @@ function _checkCredential({

if('credentialStatus' in credential) {
const {credentialStatus} = credential;
if(
Array.isArray(credentialStatus) ?
credentialStatus.some(cs => !cs.id) :
!credentialStatus.id
) {
throw new Error('"credentialStatus" must include an id.');
}
if(
Array.isArray(credentialStatus) ?
credentialStatus.some(cs => !cs.type) :
Expand Down

0 comments on commit bfad762

Please sign in to comment.