Skip to content
This repository was archived by the owner on Mar 27, 2024. It is now read-only.

Commit 4b06af1

Browse files
authored
chore: add ValidateJSONLDMap (#3579)
1 parent 97864d5 commit 4b06af1

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

pkg/doc/jsonld/validate.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/piprate/json-gold/ld"
1515

1616
"github.com/hyperledger/aries-framework-go/component/models/ld/processor"
17+
1718
"github.com/hyperledger/aries-framework-go/pkg/doc/util/json"
1819
)
1920

@@ -71,13 +72,18 @@ func getValidateOpts(options []ValidateOpts) *validateOpts {
7172

7273
// ValidateJSONLD validates jsonld structure.
7374
func ValidateJSONLD(doc string, options ...ValidateOpts) error {
74-
opts := getValidateOpts(options)
75-
7675
docMap, err := json.ToMap(doc)
7776
if err != nil {
7877
return fmt.Errorf("convert JSON-LD doc to map: %w", err)
7978
}
8079

80+
return ValidateJSONLDMap(docMap, options...)
81+
}
82+
83+
// ValidateJSONLDMap validates jsonld structure.
84+
func ValidateJSONLDMap(docMap map[string]interface{}, options ...ValidateOpts) error {
85+
opts := getValidateOpts(options)
86+
8187
jsonldProc := processor.Default()
8288

8389
docCompactedMap, err := jsonldProc.Compact(docMap,

0 commit comments

Comments
 (0)