credentialSubject maybe an object or an Array of objects
aljones15 opened this issue · 1 comments
aljones15 commented
https://www.w3.org/TR/vc-data-model/#credential-subject
Currently our assertion on credentialSubject
is that it is an object, but it can also be an Array (possibly because it is RDF).
Chai is a bit smart about this:
[].should.be.an('object')
fails.
however typeof []
is object
So we need an assertion that ensures credentialSubject
is either an object that is not an Array or is an Array that contains only objects.
This should probably be something like this:
if(Array.isArray(vc.credentialSubject)) {
for(const subject of vc.credentialSubject) {
subject.should.be.an('object');
}
return;
}
vc.credentialSubject.should.be.an('object');
That sounds like a new assertion which might be worth looking into.
aljones15 commented
closing as this has been addressed by PR 24