fact

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2023 License: BSD-2-Clause Imports: 6 Imported by: 20

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateFact

func ValidateFact(fact Fact) error

ValidateFact checks the fact to see if it valid based on its type.

Types

type Fact

type Fact struct {
	Fact string   `json:"Fact"`
	T    FactType `json:"T"`
}

Fact represents a piece of user-identifying information. This structure can be JSON marshalled and unmarshalled.

JSON example:

{
  "Fact": "john@example.com",
  "T": 1
}

func NewFact

func NewFact(ft FactType, fact string) (Fact, error)

NewFact checks if the inputted information is a valid fact on the fact type. If so, it returns a new fact object. If not, it returns a validation error.

func UnstringifyFact

func UnstringifyFact(s string) (Fact, error)

UnstringifyFact unmarshalls the stringified fact into a Fact.

func (Fact) Normalized

func (f Fact) Normalized() string

Normalized returns the fact in all uppercase letters.

func (Fact) Stringify

func (f Fact) Stringify() string

Stringify marshals the Fact for transmission for UDB. It is not a part of the fact interface.

type FactList

type FactList []Fact

FactList is a list of Fact objects. This type can be JSON marshalled and unmarshalled.

func UnstringifyFactList

func UnstringifyFactList(s string) (FactList, string, error)

UnstringifyFactList unmarshalls the stringified FactList, which consists of the fact list and optional arbitrary data, delimited by the factBreak.

func (FactList) Stringify

func (fl FactList) Stringify() string

Stringify marshals the FactList into a portable string.

type FactType

type FactType uint8
const (
	Username FactType = 0
	Email    FactType = 1
	Phone    FactType = 2
	Nickname FactType = 3
)

func UnstringifyFactType

func UnstringifyFactType(s string) (FactType, error)

UnstringifyFactType unmarshalls the stringified FactType.

func (FactType) IsValid

func (t FactType) IsValid() bool

IsValid determines if the FactType is one of the defined types.

func (FactType) String

func (t FactType) String() string

String returns the string representation of the FactType. This functions adheres to the fmt.Stringer interface.

func (FactType) Stringify

func (t FactType) Stringify() string

Stringify marshals the FactType into a portable string.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL