Closed aljones15 closed 1 year ago
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).
credentialSubject
Chai is a bit smart about this:
[].should.be.an('object') fails.
[].should.be.an('object')
however typeof [] is object
typeof []
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.
closing as this has been addressed by PR 24
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 []
isobject
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:
That sounds like a new assertion which might be worth looking into.