feat: validate user input for entity names
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/google/uuid"
|
||||
e "github.com/iliadenisov/galaxy/internal/error"
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
"github.com/iliadenisov/galaxy/internal/util"
|
||||
)
|
||||
|
||||
func (c *Controller) CreateShipType(raceName, typeName string, drive float64, ammo int, weapons, shileds, cargo float64) error {
|
||||
@@ -23,7 +24,7 @@ func (c *Cache) CreateShipType(ri int, typeName string, drive float64, ammo int,
|
||||
if err := checkShipTypeValues(drive, ammo, weapons, shileds, cargo); err != nil {
|
||||
return err
|
||||
}
|
||||
n, ok := validateTypeName(typeName)
|
||||
n, ok := util.ValidateTypeName(typeName)
|
||||
if !ok {
|
||||
return e.NewEntityTypeNameValidationError("%q", n)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user