Skip to content

Commit

Permalink
remove required on physical port id and vlan if node is type access (#19
Browse files Browse the repository at this point in the history
)

Co-authored-by: Pauline ESPALIEU <[email protected]>
  • Loading branch information
Barbeek and Pauline ESPALIEU authored Sep 18, 2024
1 parent ec92939 commit 0dbb546
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 34 deletions.
4 changes: 2 additions & 2 deletions models/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,6 @@ type CreateNode struct {
Type NodeType `json:"type" binding:"required"`
Product AddProduct `json:"product" binding:"required"`
ProviderConfig *ProviderCloudConfig `json:"providerConfig" binding:"required_if=Type cloud"`
PhysicalPortID *uuid.UUID `json:"physicalPortId,omitempty" binding:"required_if=Type access"`
Vlan int64 `json:"vlan,omitempty" binding:"required_if=Type access"`
PhysicalPortID *uuid.UUID `json:"physicalPortId,omitempty"`
Vlan int64 `json:"vlan,omitempty"`
}
32 changes: 0 additions & 32 deletions node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1305,36 +1305,4 @@ func TestCreateAccessNodeFailedValidator(t *testing.T) {

g.Expect(err.Error()).Should(Equal("Key: 'CreateNode.Product.SKU' Error:Field validation for 'SKU' failed on the 'required' tag"))
g.Expect(data).Should(BeNil())

data, err = cli.CreateNode(
context.Background(),
models.CreateNode{
Name: "node_name",
Type: models.NodeTypeAccess,
Product: models.AddProduct{
SKU: "CEQUFR5100AWS",
},
Vlan: 2,
},
workspaceID,
)

g.Expect(err.Error()).Should(Equal("Key: 'CreateNode.PhysicalPortID' Error:Field validation for 'PhysicalPortID' failed on the 'required_if' tag"))
g.Expect(data).Should(BeNil())

data, err = cli.CreateNode(
context.Background(),
models.CreateNode{
Name: "node_name",
Type: models.NodeTypeAccess,
Product: models.AddProduct{
SKU: "CEQUFR5100AWS",
},
PhysicalPortID: &physicalPortId,
},
workspaceID,
)

g.Expect(err.Error()).Should(Equal("Key: 'CreateNode.Vlan' Error:Field validation for 'Vlan' failed on the 'required_if' tag"))
g.Expect(data).Should(BeNil())
}

0 comments on commit 0dbb546

Please sign in to comment.