Skip to content

Commit

Permalink
Add lexicon.ValidateRecord
Browse files Browse the repository at this point in the history
  • Loading branch information
vkuznet committed Mar 29, 2024
1 parent 34f61bf commit 0f17a07
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

beamlines "github.com/CHESSComputing/golib/beamlines"
srvConfig "github.com/CHESSComputing/golib/config"
lexicon "github.com/CHESSComputing/golib/lexicon"
mongo "github.com/CHESSComputing/golib/mongo"
services "github.com/CHESSComputing/golib/services"
"github.com/gin-gonic/gin"
Expand Down Expand Up @@ -96,6 +97,13 @@ func DataHandler(c *gin.Context) {
if Verbose > 0 {
log.Printf("insert schema=%s record=%+v", schema, record)
}
err = lexicon.ValidateRecord(record)
if err != nil {
rec := services.Response("MetaData", http.StatusInternalServerError, services.ValidateError, err)
c.JSON(http.StatusInternalServerError, rec)
return
}

// insert record to meta-data database
attrs := srvConfig.Config.CHESSMetaData.DID.Attributes
sep := srvConfig.Config.CHESSMetaData.DID.Separator
Expand Down

0 comments on commit 0f17a07

Please sign in to comment.