tt

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2022 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckColor

func CheckColor(field string, value string) (errs []error)

CheckColor returns an error if the value is not a valid hex color

func CheckCurrency

func CheckCurrency(field string, value string) (errs []error)

CheckCurrency returns an error if the value is not a known currency

func CheckEmail

func CheckEmail(field string, value string) (errs []error)

CheckEmail returns an error if the value is not a reasonably valid email address

func CheckInArray

func CheckInArray(field string, value string, values ...string) []error

CheckInArray returns an error if the value is not in the set of provided values.

func CheckInArrayInt

func CheckInArrayInt(field string, value int, values ...int) []error

CheckInArrayInt returns an error if the value is not in the set of provided values.

func CheckInsideRange

func CheckInsideRange(field string, value float64, min float64, max float64) (errs []error)

CheckInsideRange returns an error if the value is outside of the specified range

func CheckInsideRangeInt

func CheckInsideRangeInt(field string, value int, min int, max int) (errs []error)

CheckInsideRangeInt returns an error if the value is outside of the specified range

func CheckLanguage

func CheckLanguage(field string, value string) (errs []error)

CheckLanguage returns an error if the value is not a known language

func CheckPositive

func CheckPositive(field string, value float64) (errs []error)

CheckPositive returns an error if the value is non-negative

func CheckPositiveInt

func CheckPositiveInt(field string, value int) (errs []error)

CheckPositiveInt returns an error if the value is non-negative

func CheckPresent

func CheckPresent(field string, value string) (errs []error)

CheckPresent returns an error if a string is empty

func CheckTimezone

func CheckTimezone(field string, value string) (errs []error)

CheckTimezone returns an error if the value is not a known timezone

func CheckURL

func CheckURL(field string, value string) (errs []error)

CheckURL returns an error if the value is not a reasonably valid url

func IsValidColor

func IsValidColor(color string) bool

IsValidColor check is valid color

func IsValidCurrency

func IsValidCurrency(value string) bool

IsValidCurrency check is valid currency

func IsValidEmail

func IsValidEmail(email string) bool

IsValidEmail check if valid email

func IsValidLanguage

func IsValidLanguage(value string) bool

IsValidLang check is valid language

func IsValidTimezone

func IsValidTimezone(value string) (string, bool)

IsValidTimezone check is valid timezone

func IsValidURL

func IsValidURL(url string) bool

IsValidURL check is valid url

func SecondsToString

func SecondsToString(secs int) string

SecondsToString takes seconds-since-midnight and returns a GTFS-style time.

func StringToSeconds

func StringToSeconds(value string) (int, error)

StringToSeconds parses a GTFS-style time and returns seconds since midnight.

Types

type Date

type Date struct {
	Val   time.Time
	Valid bool
}

Date is a nullable date

func NewDate

func NewDate(v time.Time) Date

func (*Date) IsZero

func (r *Date) IsZero() bool

func (Date) MarshalGQL

func (r Date) MarshalGQL(w io.Writer)

func (*Date) MarshalJSON

func (r *Date) MarshalJSON() ([]byte, error)

func (*Date) Scan

func (r *Date) Scan(src interface{}) error

func (*Date) String

func (r *Date) String() string

func (*Date) UnmarshalGQL

func (r *Date) UnmarshalGQL(src interface{}) error

func (*Date) UnmarshalJSON

func (r *Date) UnmarshalJSON(v []byte) error

func (Date) Value

func (r Date) Value() (driver.Value, error)

type Float

type Float struct {
	Val   float64
	Valid bool
}

Float is a nullable float64

func NewFloat

func NewFloat(v float64) Float

func (Float) MarshalGQL

func (r Float) MarshalGQL(w io.Writer)

func (*Float) MarshalJSON

func (r *Float) MarshalJSON() ([]byte, error)

func (*Float) Scan

func (r *Float) Scan(src interface{}) error

func (*Float) String

func (r *Float) String() string

func (*Float) UnmarshalGQL

func (r *Float) UnmarshalGQL(v interface{}) error

func (*Float) UnmarshalJSON

func (r *Float) UnmarshalJSON(v []byte) error

func (Float) Value

func (r Float) Value() (driver.Value, error)

type Geometry

type Geometry struct {
	Valid    bool
	Geometry geom.T
}

Geometry is an EWKB/GeoJSON wrapper for arbitary geometry.

func (Geometry) MarshalGQL

func (g Geometry) MarshalGQL(w io.Writer)

func (*Geometry) MarshalJSON

func (g *Geometry) MarshalJSON() ([]byte, error)

func (*Geometry) Scan

func (g *Geometry) Scan(src interface{}) error

func (Geometry) String

func (g Geometry) String() string

String returns the GeoJSON representation

func (*Geometry) UnmarshalGQL

func (g *Geometry) UnmarshalGQL(v interface{}) error

func (Geometry) Value

func (g Geometry) Value() (driver.Value, error)

type Int

type Int struct {
	Val   int
	Valid bool
}

Int is a nullable int

func NewInt

func NewInt(v int) Int

func (Int) MarshalGQL

func (r Int) MarshalGQL(w io.Writer)

func (*Int) MarshalJSON

func (r *Int) MarshalJSON() ([]byte, error)

func (*Int) Scan

func (r *Int) Scan(src interface{}) error

func (*Int) String

func (r *Int) String() string

func (*Int) UnmarshalGQL

func (r *Int) UnmarshalGQL(v interface{}) error

func (*Int) UnmarshalJSON

func (r *Int) UnmarshalJSON(v []byte) error

func (Int) Value

func (r Int) Value() (driver.Value, error)

type Ints

type Ints struct {
	Valid bool
	Val   []int
}

Ints is a nullable slice of []int

func NewInts

func NewInts(v []int) Ints

func (*Ints) Scan

func (a *Ints) Scan(value interface{}) error

func (Ints) Value

func (a Ints) Value() (driver.Value, error)

type Key

type Key struct {
	Val   string
	Valid bool
}

Key is a nullable foreign key constraint, similar to sql.NullString

func NewKey

func NewKey(v string) Key

func (*Key) Int

func (r *Key) Int() int

func (Key) MarshalGQL

func (r Key) MarshalGQL(w io.Writer)

func (*Key) MarshalJSON

func (r *Key) MarshalJSON() ([]byte, error)

func (*Key) Scan

func (r *Key) Scan(src interface{}) error

func (*Key) String

func (r *Key) String() string

func (*Key) UnmarshalGQL

func (r *Key) UnmarshalGQL(v interface{}) error

func (*Key) UnmarshalJSON

func (r *Key) UnmarshalJSON(v []byte) error

func (Key) Value

func (r Key) Value() (driver.Value, error)

type LineString

type LineString struct {
	Valid bool
	geom.LineString
}

LineString is an EWKB/SL encoded LineString

func NewLineStringFromFlatCoords

func NewLineStringFromFlatCoords(coords []float64) LineString

NewLineStringFromFlatCoords returns a new LineString from flat (3) coordinates

func (LineString) MarshalGQL

func (g LineString) MarshalGQL(w io.Writer)

func (*LineString) MarshalJSON

func (g *LineString) MarshalJSON() ([]byte, error)

func (*LineString) Scan

func (g *LineString) Scan(src interface{}) error

func (LineString) String

func (g LineString) String() string

func (*LineString) UnmarshalGQL

func (g *LineString) UnmarshalGQL(v interface{}) error

func (LineString) Value

func (g LineString) Value() (driver.Value, error)

type Point

type Point struct {
	Valid bool
	geom.Point
}

Point is an EWKB/SL encoded point

func NewPoint

func NewPoint(lon, lat float64) Point

NewPoint returns a Point from lon, lat

func (Point) MarshalGQL

func (g Point) MarshalGQL(w io.Writer)

func (*Point) MarshalJSON

func (g *Point) MarshalJSON() ([]byte, error)

func (*Point) Scan

func (g *Point) Scan(src interface{}) error

func (Point) String

func (g Point) String() string

func (*Point) UnmarshalGQL

func (g *Point) UnmarshalGQL(v interface{}) error

func (Point) Value

func (g Point) Value() (driver.Value, error)

type Polygon

type Polygon struct {
	Valid bool
	geom.Polygon
}

Polygon is an EWKB/SL encoded Polygon

func (Polygon) MarshalGQL

func (g Polygon) MarshalGQL(w io.Writer)

func (*Polygon) MarshalJSON

func (g *Polygon) MarshalJSON() ([]byte, error)

func (*Polygon) Scan

func (g *Polygon) Scan(src interface{}) error

func (Polygon) String

func (g Polygon) String() string

func (*Polygon) UnmarshalGQL

func (g *Polygon) UnmarshalGQL(v interface{}) error

func (Polygon) Value

func (g Polygon) Value() (driver.Value, error)

type RouteType

type RouteType struct {
	Code     int
	Name     string
	Category string
	Parent   int
}

RouteType contains details on each possible route_type

func GetBasicRouteType

func GetBasicRouteType(code int) (RouteType, bool)

GetBasicRouteType returns the closest approximate basic route_type for an extended route_type.

func GetRouteType

func GetRouteType(code int) (RouteType, bool)

GetRouteType returns the details for a given route_type value.

type String

type String struct {
	Val   string
	Valid bool
}

func NewString

func NewString(v string) String

func (String) MarshalGQL

func (r String) MarshalGQL(w io.Writer)

func (*String) MarshalJSON

func (r *String) MarshalJSON() ([]byte, error)

func (*String) Scan

func (r *String) Scan(src interface{}) error

func (*String) UnmarshalGQL

func (r *String) UnmarshalGQL(v interface{}) error

func (*String) UnmarshalJSON

func (r *String) UnmarshalJSON(v []byte) error

func (String) Value

func (r String) Value() (driver.Value, error)

Value returns nil if empty

type Strings

type Strings []String

Strings helps read and write []String as JSON

func (*Strings) Scan

func (a *Strings) Scan(value interface{}) error

func (Strings) Value

func (a Strings) Value() (driver.Value, error)

type Tags

type Tags struct {
	// contains filtered or unexported fields
}

Tags is a map[string]string with json and gql marshal support. This is a struct instead of bare map[string]string because of a gqlgen issue.

func (*Tags) Get

func (r *Tags) Get(k string) (string, bool)

Get a tag value by key

func (*Tags) Keys

func (r *Tags) Keys() []string

Keys return the tag keys

func (Tags) MarshalGQL

func (r Tags) MarshalGQL(w io.Writer)

func (*Tags) MarshalJSON

func (r *Tags) MarshalJSON() ([]byte, error)

func (*Tags) Scan

func (r *Tags) Scan(value interface{}) error

func (*Tags) Set

func (r *Tags) Set(k, v string)

Set a tag value

func (*Tags) UnmarshalGQL

func (r *Tags) UnmarshalGQL(v interface{}) error

func (*Tags) UnmarshalJSON

func (r *Tags) UnmarshalJSON(v []byte) error

func (Tags) Value

func (r Tags) Value() (driver.Value, error)

type Time

type Time struct {
	Val   time.Time
	Valid bool
}

Time is a nullable date without time component

func NewTime

func NewTime(v time.Time) Time

func (*Time) IsZero

func (r *Time) IsZero() bool

IsZero returns if this is a zero value.

func (Time) MarshalGQL

func (r Time) MarshalGQL(w io.Writer)

func (*Time) MarshalJSON

func (r *Time) MarshalJSON() ([]byte, error)

func (*Time) Scan

func (r *Time) Scan(src interface{}) error

func (*Time) String

func (r *Time) String() string

func (*Time) UnmarshalGQL

func (r *Time) UnmarshalGQL(v interface{}) error

func (Time) Value

func (r Time) Value() (driver.Value, error)

type WideTime

type WideTime struct {
	Seconds int
	Valid   bool
}

WideTime handles seconds since midnight, allows >24 hours.

func NewWideTime

func NewWideTime(value string) (wt WideTime, err error)

NewWideTime converts the csv string to a WideTime.

func NewWideTimeFromSeconds

func NewWideTimeFromSeconds(value int) WideTime

NewWideTimeFromSeconds creates a valid WideTime from Seconds.

func (WideTime) MarshalGQL

func (wt WideTime) MarshalGQL(w io.Writer)

func (*WideTime) Scan

func (wt *WideTime) Scan(src interface{}) error

func (*WideTime) String

func (wt *WideTime) String() string

func (*WideTime) UnmarshalGQL

func (wt *WideTime) UnmarshalGQL(v interface{}) error

func (WideTime) Value

func (wt WideTime) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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