X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=capifcore%2Finternal%2Fprovidermanagementapi%2Ftypevalidation.go;h=bb32991e3444241a826168c0e987de83a7736cc0;hb=HEAD;hp=1b2e5824dea830ad40566728fe0492b57d724484;hpb=6245ef94c3d8d2b016b8c47881dae2fcccbf054a;p=nonrtric%2Fplt%2Fsme.git diff --git a/capifcore/internal/providermanagementapi/typevalidation.go b/capifcore/internal/providermanagementapi/typevalidation.go index 1b2e582..bb32991 100644 --- a/capifcore/internal/providermanagementapi/typevalidation.go +++ b/capifcore/internal/providermanagementapi/typevalidation.go @@ -34,12 +34,15 @@ func (ri RegistrationInformation) Validate() error { } func (fd APIProviderFunctionDetails) Validate() error { + if len(strings.TrimSpace(string(fd.ApiProvFuncRole))) == 0 { + return errors.New("APIProviderFunctionDetails missing required apiProvFuncRole") + } switch role := fd.ApiProvFuncRole; role { case ApiProviderFuncRoleAEF: case ApiProviderFuncRoleAPF: case ApiProviderFuncRoleAMF: default: - return errors.New("APIProviderFunctionDetails missing required apiProvFuncRole") + return errors.New("APIProviderFunctionDetails has invalid apiProvFuncRole") } return fd.RegInfo.Validate() @@ -64,3 +67,10 @@ func (pd APIProviderEnrolmentDetails) validateFunctions() error { } return nil } + +func (pd APIProviderEnrolmentDetails) ValidateAlreadyRegistered(otherProvider APIProviderEnrolmentDetails) error { + if pd.RegSec == otherProvider.RegSec { + return errors.New("provider with identical regSec already registered") + } + return nil +}