Skip to content

Commit

Permalink
removed regex validation on nativeID (#903)
Browse files Browse the repository at this point in the history
  • Loading branch information
sawyerawesome committed Apr 26, 2023
1 parent f0baee5 commit ae79bd0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
12 changes: 2 additions & 10 deletions custom_validations.go
Expand Up @@ -1776,19 +1776,11 @@ func IsAddressAzureReserved(address string) (bool, error) {
return false, nil
}

// nativeIDRegex is the regular expression to check the format of the nativeID.
var nativeIDRegex = regexp.MustCompile(`^[a-zA-Z0-9-_#+.\/:@{}"\\,]+$`)

// ValidateCloudNodeEntity validates the CloudNode entity and all the attribute relations.
func ValidateCloudNodeEntity(c *CloudNode) error {

switch c.Type {
case CloudNodeTypeScaleGroup:
// Do nothing.
default:
if !nativeIDRegex.MatchString(c.NativeID) {
return makeValidationError("nativeID", fmt.Sprintf("'%s'is not a valid tag", c.NativeID))
}
if len(c.NativeID) == 0 {
return makeValidationError("nativeID", "Attribute 'nativeID' must not be empty")
}

if len([]byte(c.NativeID)) >= 512 {
Expand Down
2 changes: 1 addition & 1 deletion custom_validations_test.go
Expand Up @@ -5398,7 +5398,7 @@ func TestValidateCloudNodeEntity(t *testing.T) {
NativeID: "a b",
Type: CloudNodeTypeNetworkRuleSet,
},
true,
false,
},
{
"invalid",
Expand Down

0 comments on commit ae79bd0

Please sign in to comment.