Skip to content

Commit 0dbb546

Browse files
Pauline EspalieuPauline ESPALIEU
andauthored
remove required on physical port id and vlan if node is type access (#19)
Co-authored-by: Pauline ESPALIEU <paulineespalieu@MacBook-Pro-Pauline-Espalieu.local>
1 parent ec92939 commit 0dbb546

2 files changed

Lines changed: 2 additions & 34 deletions

File tree

models/node.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,6 @@ type CreateNode struct {
9292
Type NodeType `json:"type" binding:"required"`
9393
Product AddProduct `json:"product" binding:"required"`
9494
ProviderConfig *ProviderCloudConfig `json:"providerConfig" binding:"required_if=Type cloud"`
95-
PhysicalPortID *uuid.UUID `json:"physicalPortId,omitempty" binding:"required_if=Type access"`
96-
Vlan int64 `json:"vlan,omitempty" binding:"required_if=Type access"`
95+
PhysicalPortID *uuid.UUID `json:"physicalPortId,omitempty"`
96+
Vlan int64 `json:"vlan,omitempty"`
9797
}

node_test.go

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,36 +1305,4 @@ func TestCreateAccessNodeFailedValidator(t *testing.T) {
13051305

13061306
g.Expect(err.Error()).Should(Equal("Key: 'CreateNode.Product.SKU' Error:Field validation for 'SKU' failed on the 'required' tag"))
13071307
g.Expect(data).Should(BeNil())
1308-
1309-
data, err = cli.CreateNode(
1310-
context.Background(),
1311-
models.CreateNode{
1312-
Name: "node_name",
1313-
Type: models.NodeTypeAccess,
1314-
Product: models.AddProduct{
1315-
SKU: "CEQUFR5100AWS",
1316-
},
1317-
Vlan: 2,
1318-
},
1319-
workspaceID,
1320-
)
1321-
1322-
g.Expect(err.Error()).Should(Equal("Key: 'CreateNode.PhysicalPortID' Error:Field validation for 'PhysicalPortID' failed on the 'required_if' tag"))
1323-
g.Expect(data).Should(BeNil())
1324-
1325-
data, err = cli.CreateNode(
1326-
context.Background(),
1327-
models.CreateNode{
1328-
Name: "node_name",
1329-
Type: models.NodeTypeAccess,
1330-
Product: models.AddProduct{
1331-
SKU: "CEQUFR5100AWS",
1332-
},
1333-
PhysicalPortID: &physicalPortId,
1334-
},
1335-
workspaceID,
1336-
)
1337-
1338-
g.Expect(err.Error()).Should(Equal("Key: 'CreateNode.Vlan' Error:Field validation for 'Vlan' failed on the 'required_if' tag"))
1339-
g.Expect(data).Should(BeNil())
13401308
}

0 commit comments

Comments
 (0)