summaryrefslogtreecommitdiffstats
path: root/src/orchestrator/pkg/infra
diff options
context:
space:
mode:
authorRitu Sood <Ritu.Sood@intel.com>2020-04-23 21:40:06 +0000
committerGerrit Code Review <gerrit@onap.org>2020-04-23 21:40:06 +0000
commit334322f5995394dfa6a948101064634eaaf5f0b5 (patch)
treee30d1625633de0e2ffb68fe195be75a2873a5edf /src/orchestrator/pkg/infra
parentb54eda4919487b700554a27cb46b6e6b465ad180 (diff)
parent0b59486c82a9786c85438f6352636b19b83e1021 (diff)
Merge "Controller API support"
Diffstat (limited to 'src/orchestrator/pkg/infra')
-rw-r--r--src/orchestrator/pkg/infra/validation/validation.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/orchestrator/pkg/infra/validation/validation.go b/src/orchestrator/pkg/infra/validation/validation.go
index 448ea5de..c43d29ec 100644
--- a/src/orchestrator/pkg/infra/validation/validation.go
+++ b/src/orchestrator/pkg/infra/validation/validation.go
@@ -23,6 +23,7 @@ import (
"io"
"net"
"regexp"
+ "strconv"
"strings"
pkgerrors "github.com/pkg/errors"
@@ -280,6 +281,28 @@ func IsValidNumber(value, min, max int) []string {
return errs
}
+func IsValidNumberStr(value string, min, max int) []string {
+ var errs []string
+
+ if min > max {
+ errs = append(errs, "invalid constraints")
+ return errs
+ }
+
+ n, err := strconv.Atoi(value)
+ if err != nil {
+ errs = append(errs, err.Error())
+ return errs
+ }
+ if n < min {
+ errs = append(errs, "value less than minimum")
+ }
+ if n > max {
+ errs = append(errs, "value greater than maximum")
+ }
+ return errs
+}
+
/*
IsValidParameterPresent method takes in a vars map and a array of string parameters
that you expect to be present in the GET request.