github.com/choria-io/go-choria@v0.28.1-0.20240416190746-b3bf9c7d5a45/protocol/v1/schemas.go (about) 1 // Copyright (c) 2017-2022, R.I. Pienaar and the Choria Project contributors 2 // 3 // SPDX-License-Identifier: Apache-2.0 4 5 package v1 6 7 import ( 8 "errors" 9 10 "github.com/choria-io/go-choria/protocol" 11 ) 12 13 func schemaValidate(version protocol.ProtocolVersion, data []byte) (valid bool, errs []string, err error) { 14 valid, errs, err = protocol.SchemaValidate(version, data) 15 16 switch { 17 case errors.Is(err, protocol.ErrSchemaValidationFailed): 18 badJsonCtr.Inc() 19 protocolErrorCtr.Inc() 20 case !valid: 21 protocolErrorCtr.Inc() 22 invalidCtr.Inc() 23 } 24 25 return valid, errs, err 26 }