Improve validation for invoker management
[nonrtric/plt/sme.git] / capifcore / internal / invokermanagementapi / typevalidation.go
index b12ddfb..be29481 100644 (file)
@@ -22,6 +22,8 @@ package invokermanagementapi
 
 import (
        "errors"
+       "fmt"
+       "net/url"
 )
 
 func (ied *APIInvokerEnrolmentDetails) Validate() error {
@@ -29,6 +31,10 @@ func (ied *APIInvokerEnrolmentDetails) Validate() error {
                return errors.New("APIInvokerEnrolmentDetails missing required NotificationDestination")
        }
 
+       if _, err := url.ParseRequestURI(string(ied.NotificationDestination)); err != nil {
+               return fmt.Errorf("APIInvokerEnrolmentDetails has invalid NotificationDestination, err=%s", err)
+       }
+
        if ied.OnboardingInformation.ApiInvokerPublicKey == "" {
                return errors.New("APIInvokerEnrolmentDetails missing required OnboardingInformation.ApiInvokerPublicKey")
        }