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

Commit

Permalink
chore: add ValidateJSONLDMap (#3579)
Browse files Browse the repository at this point in the history
  • Loading branch information
skynet2 authored May 8, 2023
1 parent 97864d5 commit 4b06af1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pkg/doc/jsonld/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/piprate/json-gold/ld"

"github.com/hyperledger/aries-framework-go/component/models/ld/processor"

"github.com/hyperledger/aries-framework-go/pkg/doc/util/json"
)

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

// ValidateJSONLD validates jsonld structure.
func ValidateJSONLD(doc string, options ...ValidateOpts) error {
opts := getValidateOpts(options)

docMap, err := json.ToMap(doc)
if err != nil {
return fmt.Errorf("convert JSON-LD doc to map: %w", err)
}

return ValidateJSONLDMap(docMap, options...)
}

// ValidateJSONLDMap validates jsonld structure.
func ValidateJSONLDMap(docMap map[string]interface{}, options ...ValidateOpts) error {
opts := getValidateOpts(options)

jsonldProc := processor.Default()

docCompactedMap, err := jsonldProc.Compact(docMap,
Expand Down

0 comments on commit 4b06af1

Please sign in to comment.