Skip to content

Commit

Permalink
tapgarden: use asset name validator when validating seedling fields
Browse files Browse the repository at this point in the history
  • Loading branch information
ffranr committed Sep 21, 2023
1 parent f53fc45 commit d74cdf5
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions tapgarden/seedling.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ type Seedling struct {
//
// TODO(roasbeef): have this series of check be a DB level constraint?
func (c Seedling) validateFields() error {
// Validate the asset name.
err := asset.ValidateAssetName(c.AssetName)
if err != nil {
return err
}

switch {
// Only normal and collectible asset types are supported.
//
Expand All @@ -111,13 +117,6 @@ func (c Seedling) validateFields() error {
return fmt.Errorf("%v: %v", int(c.AssetType),
ErrInvalidAssetType)

// The asset name can't be blank as that's needed to generate the asset
// ID.
//
// TODO(roasbeef): also bubble up to the spec?
case c.AssetName == "":
return ErrNoAssetName

// Creating an asset with zero available supply is not allowed.
case c.Amount == 0:
return ErrInvalidAssetAmt
Expand Down

0 comments on commit d74cdf5

Please sign in to comment.