Skip to content

Commit

Permalink
Update auto generated go snappi
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Jan 16, 2024
1 parent 9da0fa9 commit abff3de
Show file tree
Hide file tree
Showing 9 changed files with 61,035 additions and 36,265 deletions.
21 changes: 21 additions & 0 deletions gosnappi/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,21 @@ func (obj *validation) validateHex(hex string) error {
return nil
}

func (obj *validation) validateOid(oid string) error {
segments := strings.Split(oid, ".")
if len(segments) < 2 {
return fmt.Errorf(fmt.Sprintf("Invalid oid value %s", oid))
}

for _, segment := range segments {
number, err := strconv.Atoi(segment)
if err != nil || 0 > number || number > 4294967295 {
return fmt.Errorf(fmt.Sprintf("Invalid oid value %s", oid))
}
}
return nil
}

func (obj *validation) validateSlice(valSlice []string, sliceType string) error {
indices := []string{}
var err error
Expand All @@ -344,6 +359,8 @@ func (obj *validation) validateSlice(valSlice []string, sliceType string) error
err = obj.validateIpv6(val)
} else if sliceType == "hex" {
err = obj.validateHex(val)
} else if sliceType == "oid" {
err = obj.validateOid(val)
} else {
return fmt.Errorf(fmt.Sprintf("Invalid slice type received <%s>", sliceType))
}
Expand Down Expand Up @@ -376,6 +393,10 @@ func (obj *validation) validateHexSlice(hex []string) error {
return obj.validateSlice(hex, "hex")
}

func (obj *validation) validateOidSlice(oid []string) error {
return obj.validateSlice(oid, "oid")
}

// TODO: restore behavior
// func (obj *validation) createMap(objName string) {
// if obj.constraints == nil {
Expand Down
Loading

0 comments on commit abff3de

Please sign in to comment.