-
Notifications
You must be signed in to change notification settings - Fork 590
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(dp): add max_ibw_mhz validation (#13293)
* fix(dp): add max_ibw_mhz validation Signed-off-by: Jarosław Jaszczuk <jaroslaw.jaszczuk@freedomfi.com> * validate that max_ibw_mhz is not less than bandwidth_mhz Signed-off-by: Jarosław Jaszczuk <jaroslaw.jaszczuk@freedomfi.com> * add MutableCbsd.ValidateModel tests Signed-off-by: Jarosław Jaszczuk <jaroslaw.jaszczuk@freedomfi.com> * reorganize validation_test.go imports Signed-off-by: Jarosław Jaszczuk <jaroslaw.jaszczuk@freedomfi.com> Co-authored-by: Jarosław Jaszczuk <jaroslaw.jaszczuk@freedomfi.com>
- Loading branch information
1 parent
f9641e2
commit e0cf136
Showing
7 changed files
with
87 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
dp/cloud/go/services/dp/obsidian/models/capabilities_swaggergen.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package models | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/go-openapi/errors" | ||
"github.com/go-openapi/strfmt" | ||
) | ||
|
||
func (m *MutableCbsd) ValidateModel(_ context.Context) error { | ||
if err := m.Validate(strfmt.Default); err != nil { | ||
return err | ||
} | ||
var res []error | ||
if !*m.GrantRedundancy && *m.CarrierAggregationEnabled { | ||
err := fmt.Errorf("grant_redundancy cannot be set to false when carrier_aggregation_enabled is enabled") | ||
res = append(res, err) | ||
} | ||
if m.Capabilities.MaxIbwMhz < m.FrequencyPreferences.BandwidthMhz { | ||
err := fmt.Errorf("max_ibw_mhz cannot be less than bandwidth_mhz") | ||
res = append(res, err) | ||
} | ||
if len(res) > 0 { | ||
return errors.CompositeValidationError(res...) | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.