mirror of
https://github.com/hanzo-fi/stack.git
synced 2026-10-30 20:34:43 +00:00
28 lines
503 B
Go
28 lines
503 B
Go
package machine
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
ledger "github.com/formancehq/ledger/internal"
|
|
)
|
|
|
|
type Asset string
|
|
|
|
func (Asset) GetType() Type { return TypeAsset }
|
|
func (a Asset) String() string {
|
|
return fmt.Sprintf("%v", string(a))
|
|
}
|
|
|
|
type HasAsset interface {
|
|
GetAsset() Asset
|
|
}
|
|
|
|
func (a Asset) GetAsset() Asset { return a }
|
|
|
|
func ValidateAsset(ass Asset) error {
|
|
if !ledger.AssetRegexp.MatchString(string(ass)) {
|
|
return fmt.Errorf("asset should respect pattern '%s'", ledger.AssetPattern)
|
|
}
|
|
return nil
|
|
}
|