func (tf *TokenFormat) FromString(value string) error {
	value = strings.ToLower(value)
	switch value {
	case "psa-iat", "psa_iat", "psa", fmt.Sprint(int(PsaIatToken)):
		*tf = PsaIatToken
	case "dice", fmt.Sprint(int(DiceToken)):
		*tf = DiceToken
	default:
		match := tokenRegex.FindStringSubmatch(value)
		if match == nil {
			return fmt.Errorf("invalid TokenFormat value: %q", value)
		}
		i, err := strconv.Atoi(match[1])
		if err != nil {
			return fmt.Errorf("invalid TokenFormat value: %q; got: %v", value, err)
		}
		*tf = TokenFormat(i)
	}
	return nil
}
FromString sets the TokenFormat from a string by either converting a name or
a string representation of a number.
package common
import (
	"encoding/json"
	"fmt"
	"math"
	"regexp"
	"strconv"
	"strings"
)
type TokenFormat int
func (tf TokenFormat) String() string {
	switch tf {
	case PsaIatToken:
		return "psa"
	case DiceToken:
		return "dice"
	default:
		return fmt.Sprintf("TokenFormat(%d)", tf)
	}
}
var tokenRegex = regexp.MustCompile(`tokenformat\((\d+)\)`)