mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
PublicDashboards: refactor using new grafana error types (#58078)
This commit is contained in:
committed by
GitHub
parent
5f5b3521d9
commit
ae30a0688a
@@ -1,15 +1,13 @@
|
||||
package validation
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
. "github.com/grafana/grafana/pkg/services/publicdashboards/models"
|
||||
)
|
||||
|
||||
func ValidatePublicDashboard(dto *SavePublicDashboardDTO, dashboard *models.Dashboard) error {
|
||||
if hasTemplateVariables(dashboard) {
|
||||
return ErrPublicDashboardHasTemplateVariables
|
||||
return ErrPublicDashboardHasTemplateVariables.Errorf("ValidateSavePublicDashboard: public dashboard has template variables")
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -23,11 +21,11 @@ func hasTemplateVariables(dashboard *models.Dashboard) bool {
|
||||
|
||||
func ValidateQueryPublicDashboardRequest(req PublicDashboardQueryDTO) error {
|
||||
if req.IntervalMs < 0 {
|
||||
return fmt.Errorf("intervalMS should be greater than 0")
|
||||
return ErrInvalidInterval.Errorf("ValidateQueryPublicDashboardRequest: intervalMS should be greater than 0")
|
||||
}
|
||||
|
||||
if req.MaxDataPoints < 0 {
|
||||
return fmt.Errorf("maxDataPoints should be greater than 0")
|
||||
return ErrInvalidMaxDataPoints.Errorf("ValidateQueryPublicDashboardRequest: maxDataPoints should be greater than 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user