2 // ========================LICENSE_START=================================
5 // Copyright (C) 2023: Nordix Foundation
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 // ========================LICENSE_END===================================
21 package providermanagementapi
29 func (ri RegistrationInformation) Validate() error {
30 if len(strings.TrimSpace(ri.ApiProvPubKey)) == 0 {
31 return errors.New("RegistrationInformation missing required apiProvPubKey")
36 func (fd APIProviderFunctionDetails) Validate() error {
37 switch role := fd.ApiProvFuncRole; role {
38 case ApiProviderFuncRoleAEF:
39 case ApiProviderFuncRoleAPF:
40 case ApiProviderFuncRoleAMF:
42 return errors.New("APIProviderFunctionDetails missing required apiProvFuncRole")
45 return fd.RegInfo.Validate()
48 func (pd APIProviderEnrolmentDetails) Validate() error {
49 if len(strings.TrimSpace(pd.RegSec)) == 0 {
50 return errors.New("APIProviderEnrolmentDetails missing required regSec")
52 if pd.ApiProvFuncs != nil {
53 return pd.validateFunctions()
58 func (pd APIProviderEnrolmentDetails) validateFunctions() error {
59 for _, function := range *pd.ApiProvFuncs {
60 err := function.Validate()
62 return fmt.Errorf("apiProvFuncs contains invalid function: %s", err)