Skip to main content
Glama

Controtto

by contre95
assets.go1.01 kB
package pnl import ( "errors" "regexp" "slices" ) type InvalidAsset error func (a *Asset) Validate() (*Asset, error) { hexColorPattern := `^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$` re := regexp.MustCompile(hexColorPattern) if !re.MatchString(a.Color) { return nil, InvalidAsset(errors.New("Wrong color string")) } if !slices.Contains(GetValidTypes(), a.Type) { return nil, InvalidAsset(errors.New("Invalid Asset Type")) } if len(a.Symbol) < 3 || len(a.Symbol) > 8 { return nil, InvalidAsset(errors.New("Invalid Asset Symbol")) } if len(a.Name) < 1 || len(a.Name) > 24 { return nil, InvalidAsset(errors.New("Invalid Asset Name")) } return a, nil } // TODO: Define invariants // NewAsset reutrns a new Asset and validates it's invariants func NewAsset(symbol, color, name, countryCode, assetType string) (*Asset, error) { a := Asset{ Symbol: symbol, Color: color, Name: name, Type: AssetType(assetType), CountryCode: countryCode, } return a.Validate() }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/contre95/controtto'

If you have feedback or need assistance with the MCP directory API, please join our Discord server