Skip to content

Commit

Permalink
Fixing subnet regex to take range
Browse files Browse the repository at this point in the history
  • Loading branch information
dvavili committed Mar 25, 2016
1 parent 9a9b401 commit 9ac4bb6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion contivModel.go
Original file line number Diff line number Diff line change
Expand Up @@ -1868,7 +1868,7 @@ func ValidateNetwork(obj *Network) error {
return errors.New("networkName string too long")
}

subnetMatch := regexp.MustCompile("^([0-9]{1,3}?.[0-9]{1,3}?.[0-9]{1,3}?.[0-9]{1,3}?/[0-9]{1,2}?)$")
subnetMatch := regexp.MustCompile("^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3})(\\-(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9]))?/(3[0-1]|2[0-9]|1[0-9]|[1-9])$")
if subnetMatch.MatchString(obj.Subnet) == false {
return errors.New("subnet string invalid format")
}
Expand Down
2 changes: 1 addition & 1 deletion network.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"subnet": {
"type": "string",
"format": "^([0-9]{1,3}?.[0-9]{1,3}?.[0-9]{1,3}?.[0-9]{1,3}?/[0-9]{1,2}?)$",
"format": "^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\\\\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3})(\\\\-(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9]))?/(3[0-1]|2[0-9]|1[0-9]|[1-9])$",
"title": "Subnet",
"showSummary": true
},
Expand Down

0 comments on commit 9ac4bb6

Please sign in to comment.